log4j
diff --git a/tests/examples/JDBC/JDBCDemo/readme.md b/tests/examples/JDBC/JDBCDemo/readme.md
index 9b8790adaddb20246232392dd323ec502102fa18..e348e458fe938c4f2381c448f3c15e60af27040e 100644
--- a/tests/examples/JDBC/JDBCDemo/readme.md
+++ b/tests/examples/JDBC/JDBCDemo/readme.md
@@ -6,10 +6,24 @@ TDengine's JDBC demo project is organized in a Maven way so that users can easil
Make sure you have already installed a tdengine client on your current develop environment.
Download the tdengine package on our website: ``https://www.taosdata.com/cn/all-downloads/`` and install the client.
+## How to run jdbcChecker
+mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcChecker" -Dexec.args="-host localhost"
+
+## How to run jdbcTaosDemo
+run command:
+ mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.jdbcTaosdemo.JdbcTaosdemo"
+and run with your customed args
+mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.jdbcTaosdemo.JdbcTaosdemo" -Dexec.args="-host localhost"
+
## Compile the Demo Code and Run It
+
To compile the demo project, go to the source directory ``TDengine/tests/examples/JDBC/JDBCDemo`` and execute
-mvn clean package assembly:single
+
+
+mvn clean package assembly:single
+
+
The ``pom.xml`` is configured to package all the dependencies into one executable jar file.
To run it, go to ``examples/JDBC/JDBCDemo/target`` and execute
-java -jar jdbcChecker-SNAPSHOT-jar-with-dependencies.jar -host localhost
\ No newline at end of file
+java -jar jdbcChecker-SNAPSHOT-jar-with-dependencies.jar -host localhost
diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java
index 82613037dbccd3be1f2c8a85a2f25e7a25ffad01..36745a93941cc690f37d06d9a3662605723bbd2c 100644
--- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java
+++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java
@@ -14,9 +14,9 @@ public final class JdbcTaosdemoConfig {
//Destination database. Default is 'test'
private String dbName = "test";
//keep
- private int keep = 3650;
+ private int keep = 36500;
//days
- private int days = 10;
+ private int days = 120;
//Super table Name. Default is 'meters'
private String stbName = "meters";
diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java
index a35628bb58c6630d92bd2b6aebb09f9912e57536..644de52dd3e75a77c2d635a6f5328f186259096c 100644
--- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java
+++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java
@@ -41,7 +41,7 @@ public class InsertTableTask implements Runnable {
long ts = start.toEpochMilli() + (j * timeGap);
// insert data into echo table
for (int i = startTbIndex; i < startTbIndex + tableNumber; i++) {
- String sql = SqlSpeller.insertOneRowSQL(config.getDbName(), config.getTbPrefix(), i + 1, ts);
+ String sql = SqlSpeller.insertBatchSizeRowsSQL(config.getDbName(), config.getTbPrefix(), i + 1, ts, config.getNumberOfRecordsPerRequest());
logger.info(Thread.currentThread().getName() + ">>> " + sql);
Statement statement = connection.createStatement();
statement.execute(sql);
diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c
index be60a88ad70721bd6281d9ca8f1d73263a788532..e08d667d6be42bef3dc4e058fab10ac68f0809e0 100644
--- a/tests/examples/c/apitest.c
+++ b/tests/examples/c/apitest.c
@@ -79,11 +79,11 @@ static int print_result(TAOS_RES* res, int blockFetch) {
if (blockFetch) {
int rows = 0;
while ((rows = taos_fetch_block(res, &row))) {
- for (int i = 0; i < rows; i++) {
- char temp[256];
- taos_print_row(temp, row + i, fields, num_fields);
- puts(temp);
- }
+ //for (int i = 0; i < rows; i++) {
+ // char temp[256];
+ // taos_print_row(temp, row + i, fields, num_fields);
+ // puts(temp);
+ //}
nRows += rows;
}
} else {
@@ -498,4 +498,4 @@ int main(int argc, char *argv[]) {
taos_close(taos);
taos_cleanup();
-}
\ No newline at end of file
+}
diff --git a/tests/examples/c/subscribe.c b/tests/examples/c/subscribe.c
index 8368af18f7831d9c2cbb7402104b1c59042eda72..cdd8ddaf7f6c4d2e5088ef36cc00ad77a0c8ebc9 100644
--- a/tests/examples/c/subscribe.c
+++ b/tests/examples/c/subscribe.c
@@ -19,10 +19,10 @@ void print_result(TAOS_RES* res, int blockFetch) {
if (blockFetch) {
nRows = taos_fetch_block(res, &row);
- for (int i = 0; i < nRows; i++) {
- taos_print_row(buf, row + i, fields, num_fields);
- puts(buf);
- }
+ //for (int i = 0; i < nRows; i++) {
+ // taos_print_row(buf, row + i, fields, num_fields);
+ // puts(buf);
+ //}
} else {
while ((row = taos_fetch_row(res))) {
taos_print_row(buf, row, fields, num_fields);
diff --git a/tests/pytest/client/alterDatabase.py b/tests/pytest/client/alterDatabase.py
index fa397d16c57625d53f6f1b2772afa99ade314e1a..8191312cc060f9c20632911c956065f777d47079 100644
--- a/tests/pytest/client/alterDatabase.py
+++ b/tests/pytest/client/alterDatabase.py
@@ -32,9 +32,9 @@ class TDTestCase:
tdSql.query("show databases")
tdSql.checkData(0, 14, 2)
- tdSql.execute("alter database db keep 365")
+ tdSql.execute("alter database db keep 365,365,365")
tdSql.query("show databases")
- tdSql.checkData(0, 7, "3650,3650,365")
+ tdSql.checkData(0, 7, "365,365,365")
tdSql.execute("alter database db quorum 2")
tdSql.query("show databases")
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/crash_gen/crash_gen_main.py b/tests/pytest/crash_gen/crash_gen_main.py
index 8d68457ec8d07c9c00f8b8fd0a11e2f25284ce4a..e2ce4b26fa2fa8cc9c601218c1bf19d838b57c46 100755
--- a/tests/pytest/crash_gen/crash_gen_main.py
+++ b/tests/pytest/crash_gen/crash_gen_main.py
@@ -352,6 +352,12 @@ class ThreadCoordinator:
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")
+ traceback.print_stack()
+ transitionFailed = True
+ self._te = None # Not running any more
+ self._execStats.registerFailure("State transition error")
else:
raise
# return transitionFailed # Why did we have this??!!
@@ -388,12 +394,20 @@ class ThreadCoordinator:
self._syncAtBarrier() # For now just cross the barrier
Progress.emit(Progress.END_THREAD_STEP)
except threading.BrokenBarrierError as err:
- Logging.info("Main loop aborted, caused by worker thread(s) time-out")
self._execStats.registerFailure("Aborted due to worker thread timeout")
- print("\n\nWorker Thread time-out detected, TAOS related threads are:")
+ 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"
@@ -701,7 +715,7 @@ class AnyState:
# task.logDebug("Task success found")
sCnt += 1
if (sCnt >= 2):
- raise RuntimeError(
+ raise CrashGenError(
"Unexpected more than 1 success with task: {}".format(cls))
def assertIfExistThenSuccess(self, tasks, cls):
@@ -714,7 +728,7 @@ class AnyState:
if task.isSuccess():
sCnt += 1
if (exists and sCnt <= 0):
- raise RuntimeError("Unexpected zero success for task type: {}, from tasks: {}"
+ raise CrashGenError("Unexpected zero success for task type: {}, from tasks: {}"
.format(cls, tasks))
def assertNoTask(self, tasks, cls):
@@ -727,7 +741,7 @@ class AnyState:
for task in tasks:
if isinstance(task, cls):
if task.isSuccess():
- raise RuntimeError(
+ raise CrashGenError(
"Unexpected successful task: {}".format(cls))
def hasSuccess(self, tasks, cls):
@@ -926,8 +940,9 @@ class StateMechine:
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, dbName): # no regular tables
+ 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
@@ -1050,9 +1065,8 @@ class Database:
def getFixedSuperTableName(cls):
return "fs_table"
- @classmethod
- def getFixedSuperTable(cls) -> TdSuperTable:
- return TdSuperTable(cls.getFixedSuperTableName())
+ 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
@@ -1107,6 +1121,11 @@ class Database:
# 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:
@@ -1240,7 +1259,7 @@ class Task():
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
+ # 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
@@ -1569,8 +1588,8 @@ class TaskCreateSuperTable(StateTransitionTask):
sTable = self._db.getFixedSuperTable() # type: TdSuperTable
# wt.execSql("use db") # should always be in place
- sTable.create(wt.getDbConn(), self._db.getName(),
- {'ts':'timestamp', 'speed':'int'}, {'b':'binary(200)', 'f':'float'},
+ sTable.create(wt.getDbConn(),
+ {'ts':'TIMESTAMP', 'speed':'INT', 'color':'BINARY(16)'}, {'b':'BINARY(200)', 'f':'FLOAT'},
dropIfExists = True
)
# self.execWtSql(wt,"create table db.{} (ts timestamp, speed int) tags (b binary(200), f float) ".format(tblName))
@@ -1579,30 +1598,33 @@ class TaskCreateSuperTable(StateTransitionTask):
class TdSuperTable:
- def __init__(self, stName):
+ def __init__(self, stName, dbName):
self._stName = stName
+ self._dbName = dbName
def getName(self):
return self._stName
- def drop(self, dbc, dbName, skipCheck = False):
- if self.exists(dbc, dbName) : # if myself exists
+ 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, dbName):
- dbc.execute("USE " + dbName)
+ 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, dbName, cols: dict, tags: dict,
+ def create(self, dbc, cols: dict, tags: dict,
dropIfExists = False
):
-
'''Creating a super table'''
+
+ dbName = self._dbName
dbc.execute("USE " + dbName)
fullTableName = dbName + '.' + self._stName
if dbc.existsSuperTable(self._stName):
@@ -1623,7 +1645,8 @@ class TdSuperTable:
)
dbc.execute(sql)
- def getRegTables(self, dbc: DbConn, dbName: str):
+ 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:
@@ -1634,10 +1657,11 @@ class TdSuperTable:
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, dbName: str):
- return dbc.query("SELECT * FROM {}.{}".format(dbName, self._stName)) > 0
+ def hasRegTables(self, dbc: DbConn):
+ return dbc.query("SELECT * FROM {}.{}".format(self._dbName, self._stName)) > 0
- def ensureTable(self, task: Task, dbc: DbConn, dbName: str, regTableName: str):
+ def ensureTable(self, task: Task, dbc: DbConn, regTableName: str):
+ 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
@@ -1650,15 +1674,15 @@ class TdSuperTable:
# print("(" + fullTableName[-3:] + ")", end="", flush=True)
try:
sql = "CREATE TABLE {} USING {}.{} tags ({})".format(
- fullTableName, dbName, self._stName, self._getTagStrForSql(dbc, dbName)
+ fullTableName, dbName, self._stName, self._getTagStrForSql(dbc)
)
dbc.execute(sql)
finally:
if task is not None:
task.unlockTable(fullTableName) # no matter what
- def _getTagStrForSql(self, dbc, dbName: str) :
- tags = self._getTags(dbc, dbName)
+ def _getTagStrForSql(self, dbc) :
+ tags = self._getTags(dbc)
tagStrs = []
for tagName in tags:
tagType = tags[tagName]
@@ -1672,36 +1696,86 @@ class TdSuperTable:
raise RuntimeError("Unexpected tag type: {}".format(tagType))
return ", ".join(tagStrs)
- def _getTags(self, dbc, dbName) -> dict:
- dbc.query("DESCRIBE {}.{}".format(dbName, self._stName))
+ 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, dbName, tagName, tagType):
- if tagName in self._getTags(dbc, dbName): # already
+ def addTag(self, dbc, tagName, tagType):
+ if tagName in self._getTags(dbc): # already
return
# sTable.addTag("extraTag", "int")
- sql = "alter table {}.{} add tag {} {}".format(dbName, self._stName, tagName, tagType)
+ sql = "alter table {}.{} add tag {} {}".format(
+ self._dbName, self._stName, tagName, tagType)
dbc.execute(sql)
- def dropTag(self, dbc, dbName, tagName):
- if not tagName in self._getTags(dbc, dbName): # don't have this tag
+ def dropTag(self, dbc, tagName):
+ if not tagName in self._getTags(dbc): # don't have this tag
return
- sql = "alter table {}.{} drop tag {}".format(dbName, self._stName, tagName)
+ sql = "alter table {}.{} drop tag {}".format(self._dbName, self._stName, tagName)
dbc.execute(sql)
- def changeTag(self, dbc, dbName, oldTag, newTag):
- tags = self._getTags(dbc, dbName)
+ 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(dbName, self._stName, oldTag, newTag)
+ 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)',
+ # Transformation Functions
+ # 'diff(speed)', # TODO: no supported?!
+ 'spread(speed)'
+ ]) # TODO: add more from 'top'
+
+
+ if aggExpr not in ['stddev(speed)']: #TODO: STDDEV not valid for super tables?!
+ 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):
@@ -1716,10 +1790,8 @@ class TaskReadData(StateTransitionTask):
# return True # always
# return gSvcMgr.isActive() # only if it's running TODO: race condition here
- def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
- sTable = self._db.getFixedSuperTable()
-
- # 1 in 5 chance, simulate a broken connection, only if service stable (not restarting)
+ 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)
@@ -1744,43 +1816,36 @@ class TaskReadData(StateTransitionTask):
return # TODO: fix server restart status race condtion
+ def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
+ self._reconnectIfNeeded(wt)
+
dbc = wt.getDbConn()
- dbName = self._db.getName()
- for rTbName in sTable.getRegTables(dbc, dbName): # regular tables
- 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)',
- # Transformation Functions
- # 'diff(speed)', # TODO: no supported?!
- 'spread(speed)'
- ]) # TODO: add more from 'top'
- filterExpr = Dice.choice([ # TODO: add various kind of WHERE conditions
- None
- ])
+ sTable = self._db.getFixedSuperTable()
+
+ for q in sTable.generateQueries(dbc): # regular tables
try:
- # Run the query against the regular table first
- dbc.execute("select {} from {}.{}".format(aggExpr, dbName, rTbName))
- # Then run it against the super table
- if aggExpr not in ['stddev(speed)']: #TODO: STDDEV not valid for super tables?!
- dbc.execute("select {} from {}.{}".format(aggExpr, dbName, sTable.getName()))
+ 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):
@@ -1837,19 +1902,18 @@ class TaskAlterTags(StateTransitionTask):
# tblName = self._dbManager.getFixedSuperTableName()
dbc = wt.getDbConn()
sTable = self._db.getFixedSuperTable()
- dbName = self._db.getName()
dice = Dice.throw(4)
if dice == 0:
- sTable.addTag(dbc, dbName, "extraTag", "int")
+ sTable.addTag(dbc, "extraTag", "int")
# sql = "alter table db.{} add tag extraTag int".format(tblName)
elif dice == 1:
- sTable.dropTag(dbc, dbName, "extraTag")
+ sTable.dropTag(dbc, "extraTag")
# sql = "alter table db.{} drop tag extraTag".format(tblName)
elif dice == 2:
- sTable.dropTag(dbc, dbName, "newTag")
+ sTable.dropTag(dbc, "newTag")
# sql = "alter table db.{} drop tag newTag".format(tblName)
else: # dice == 3
- sTable.changeTag(dbc, dbName, "extraTag", "newTag")
+ sTable.changeTag(dbc, "extraTag", "newTag")
# sql = "alter table db.{} change tag extraTag newTag".format(tblName)
class TaskRestartService(StateTransitionTask):
@@ -1920,15 +1984,17 @@ class TaskAddData(StateTransitionTask):
for j in range(numRecords): # number of records per table
nextInt = db.getNextInt()
nextTick = db.getNextTick()
- sql += "('{}', {});".format(nextTick, nextInt)
+ nextColor = db.getNextColor()
+ sql += "('{}', {}, '{}');".format(nextTick, nextInt, nextColor)
dbc.execute(sql)
- def _addData(self, db, dbc, regTableName, te: TaskExecutor): # implied: NOT in batches
+ def _addData(self, db: Database, dbc, regTableName, te: TaskExecutor): # implied: NOT in batches
numRecords = self.LARGE_NUMBER_OF_RECORDS if gConfig.larger_data else self.SMALL_NUMBER_OF_RECORDS
for j in range(numRecords): # number of records per table
nextInt = db.getNextInt()
nextTick = db.getNextTick()
+ nextColor = db.getNextColor()
if gConfig.record_ops:
self.prepToRecordOps()
self.fAddLogReady.write("Ready to write {} to {}\n".format(nextInt, regTableName))
@@ -1942,11 +2008,11 @@ class TaskAddData(StateTransitionTask):
# print("_w" + str(nextInt % 100), end="", flush=True) # Trace what was written
try:
- sql = "insert into {} values ('{}', {});".format( # removed: tags ('{}', {})
+ sql = "insert into {} values ('{}', {}, '{}');".format( # removed: tags ('{}', {})
fullTableName,
# ds.getFixedSuperTableName(),
# ds.getNextBinary(), ds.getNextFloat(),
- nextTick, nextInt)
+ nextTick, nextInt, nextColor)
dbc.execute(sql)
except: # Any exception at all
if gConfig.verify_data:
@@ -1964,10 +2030,10 @@ class TaskAddData(StateTransitionTask):
.format(nextInt, readBack), 0x999)
except taos.error.ProgrammingError as err:
errno = Helper.convertErrno(err.errno)
- if errno in [0x991, 0x992] : # not a single result
+ if errno in [CrashGenError.INVALID_EMPTY_RESULT, CrashGenError.INVALID_MULTIPLE_RESULT] : # not a single result
raise taos.error.ProgrammingError(
"Failed to read back same data for tick: {}, wrote: {}, read: {}"
- .format(nextTick, nextInt, "Empty Result" if errno==0x991 else "Multiple Result"),
+ .format(nextTick, nextInt, "Empty Result" if errno == CrashGenError.INVALID_EMPTY_RESULT else "Multiple Result"),
errno)
elif errno in [0x218, 0x362]: # table doesn't exist
# do nothing
@@ -2000,11 +2066,12 @@ class TaskAddData(StateTransitionTask):
else:
self.activeTable.add(i) # marking it active
+ dbName = db.getName()
sTable = db.getFixedSuperTable()
regTableName = self.getRegTableName(i) # "db.reg_table_{}".format(i)
- fullTableName = db.getName() + '.' + regTableName
+ fullTableName = dbName + '.' + regTableName
# self._lockTable(fullTableName) # "create table" below. Stop it if the table is "locked"
- sTable.ensureTable(self, wt.getDbConn(), db.getName(), regTableName) # Ensure the table exists
+ sTable.ensureTable(self, wt.getDbConn(), regTableName) # Ensure the table exists
# self._unlockTable(fullTableName)
if Dice.throw(1) == 0: # 1 in 2 chance
@@ -2024,7 +2091,7 @@ class ThreadStacks: # stack info for all threads
self._allStacks[th.native_id] = stack
def print(self, filteredEndName = None, filterInternal = False):
- for thNid, stack in self._allStacks.items(): # for each thread
+ for thNid, 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
@@ -2036,9 +2103,9 @@ class ThreadStacks: # stack info for all threads
'__init__']: # the thread that extracted the stack
continue # ignore
# Now print
- print("\n<----- Thread Info for LWP/ID: {} (Execution stopped at Bottom Frame) <-----".format(thNid))
+ print("\n<----- Thread Info for LWP/ID: {} (most recent call last) <-----".format(thNid))
stackFrame = 0
- for frame in stack:
+ 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))
diff --git a/tests/pytest/crash_gen/db.py b/tests/pytest/crash_gen/db.py
index 2a4b362f82c4516195becf78ef9771b7c62c3c41..855e18be55fd5ae0d88865644a2ebfc836b7ccf3 100644
--- a/tests/pytest/crash_gen/db.py
+++ b/tests/pytest/crash_gen/db.py
@@ -78,7 +78,7 @@ class DbConn:
if nRows != 1:
raise taos.error.ProgrammingError(
"Unexpected result for query: {}, rows = {}".format(sql, nRows),
- (0x991 if nRows==0 else 0x992)
+ (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))
@@ -349,7 +349,8 @@ class DbConnNative(DbConn):
def execute(self, sql):
if (not self.isOpen):
- raise RuntimeError("Cannot execute database commands until connection is open")
+ 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)
@@ -360,8 +361,8 @@ class DbConnNative(DbConn):
def query(self, sql): # return rows affected
if (not self.isOpen):
- raise RuntimeError(
- "Cannot query database until connection is open")
+ 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)
diff --git a/tests/pytest/crash_gen/misc.py b/tests/pytest/crash_gen/misc.py
index 2d2ce99d95582809a8940a8d777bc166b633747c..a374ed943b41b52c2ccbee0825bca3080ed43ea9 100644
--- a/tests/pytest/crash_gen/misc.py
+++ b/tests/pytest/crash_gen/misc.py
@@ -3,14 +3,20 @@ import random
import logging
import os
+import taos
-class CrashGenError(Exception):
- def __init__(self, msg=None, errno=None):
- self.msg = msg
- self.errno = errno
- def __str__(self):
- return self.msg
+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):
@@ -168,6 +174,7 @@ class Progress:
SERVICE_RECONNECT_FAILURE = 6
SERVICE_START_NAP = 7
CREATE_TABLE_ATTEMPT = 8
+ QUERY_GROUP_BY = 9
tokens = {
STEP_BOUNDARY: '.',
@@ -178,7 +185,8 @@ class Progress:
SERVICE_RECONNECT_SUCCESS: '.r>',
SERVICE_RECONNECT_FAILURE: '.xr>',
SERVICE_START_NAP: '_zz',
- CREATE_TABLE_ATTEMPT: '_c',
+ CREATE_TABLE_ATTEMPT: 'c',
+ QUERY_GROUP_BY: 'g',
}
@classmethod
diff --git a/tests/pytest/crash_gen/service_manager.py b/tests/pytest/crash_gen/service_manager.py
index d249abc4396462b6dbacbfcbb1f6619e48161c3b..ae6f8d5d3a5a4d6a8bf745a48ec2368aa5e832ad 100644
--- a/tests/pytest/crash_gen/service_manager.py
+++ b/tests/pytest/crash_gen/service_manager.py
@@ -51,10 +51,12 @@ class TdeInstance():
def prepareGcovEnv(cls, env):
# Ref: https://gcc.gnu.org/onlinedocs/gcc/Cross-profiling.html
bPath = cls._getBuildPath() # build PATH
- numSegments = len(bPath.split('/')) - 1 # "/x/TDengine/build" should yield 3
- numSegments = numSegments - 1 # DEBUG only
- env['GCOV_PREFIX'] = bPath + '/svc_gcov'
+ 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'] ))
@@ -258,14 +260,15 @@ class TdeSubProcess:
TdeInstance.prepareGcovEnv(myEnv)
# print(myEnv)
- # print(myEnv.items())
+ # print("Starting TDengine with env: ", myEnv.items())
# print("Starting TDengine via Shell: {}".format(cmdLineStr))
useShell = True
self.subProcess = subprocess.Popen(
- ' '.join(cmdLine) if useShell else cmdLine,
- shell=useShell,
- # svcCmdSingle, shell=True, # capture core dump?
+ # ' '.join(cmdLine) if useShell else cmdLine,
+ # shell=useShell,
+ ' '.join(cmdLine),
+ shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
# bufsize=1, # not supported in binary mode
@@ -273,7 +276,8 @@ class TdeSubProcess:
env=myEnv
) # had text=True, which interferred with reading EOF
- STOP_SIGNAL = signal.SIGKILL # What signal to use (in kill) to stop a taosd process?
+ STOP_SIGNAL = signal.SIGKILL # 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):
"""
@@ -320,8 +324,12 @@ class TdeSubProcess:
retCode = self.subProcess.returncode # should always be there
# May throw subprocess.TimeoutExpired exception above, therefore
# The process is guranteed to have ended by now
- self.subProcess = None
- if retCode != 0: # != (- signal.SIGINT):
+ self.subProcess = None
+ if retCode == self.SIG_KILL_RETCODE:
+ Logging.info("TSP.stop(): sub proc KILLED, as expected")
+ elif retCode == (- self.STOP_SIGNAL):
+ Logging.info("TSP.stop(), sub process STOPPED, as expected")
+ elif retCode != 0: # != (- signal.SIGINT):
Logging.error("TSP.stop(): Failed to stop sub proc properly w/ SIG {}, retCode={}".format(
self.STOP_SIGNAL, retCode))
else:
diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh
index 0e3b482e3da2c6618edd64c5dd004e8812078d99..dc2c0099b4a1477755543b16312708beb98ade18 100755
--- a/tests/pytest/fulltest.sh
+++ b/tests/pytest/fulltest.sh
@@ -19,6 +19,7 @@ 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 table/alter_wal0.py
python3 ./test.py -f table/column_name.py
@@ -158,7 +159,11 @@ python3 ./test.py -f query/bug1471.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/bug2218.py
+python3 ./test.py -f query/bug2117.py
+python3 ./test.py -f query/bug2143.py
+python3 ./test.py -f query/sliding.py
+python3 ./test.py -f query/unionAllTest.py
#stream
python3 ./test.py -f stream/metric_1.py
@@ -175,6 +180,7 @@ python3 ./test.py -f alter/alter_table_crash.py
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
# Misc
python3 testCompress.py
@@ -209,6 +215,7 @@ python3 test.py -f query/queryFillTest.py
python3 test.py -f tools/taosdemoTest.py
python3 test.py -f tools/taosdumpTest.py
python3 test.py -f tools/lowaTest.py
+python3 test.py -f tools/taosdemoTest2.py
# subscribe
python3 test.py -f subscribe/singlemeter.py
@@ -228,6 +235,7 @@ 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/bug_td2279.py
# wal
python3 ./test.py -f wal/addOldWalTest.py
\ 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..3d0b1ef83fe5841826ad0ab80384b5320662e104
--- /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/linux/python2/
+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/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/insertFromCSVOurofOrder.py b/tests/pytest/insert/insertFromCSVOurofOrder.py
new file mode 100644
index 0000000000000000000000000000000000000000..d4de85b7e93e78ad12962c54fbd1014615dc8e3b
--- /dev/null
+++ b/tests/pytest/insert/insertFromCSVOurofOrder.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 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
+
+ def writeCSV(self):
+ with open('test3.csv','w', encoding='utf-8', newline='') as csvFile:
+ writer = csv.writer(csvFile, dialect='excel')
+ for i in range(1000000):
+ newTimestamp = self.ts + random.randint(10000000, 10000000000) + random.randint(1000, 10000000) + random.randint(1, 1000)
+ 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)])
+
+ 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):
+ 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 'outoforder.csv'")
+ duration = time.time() - startTime
+ print("Out of Order - Insert time: %d" % duration)
+ tdSql.query("select count(*) from t1")
+ rows = tdSql.getData(0, 0)
+
+ tdSql.execute("create table t2(ts timestamp, c1 int, c2 float, c3 int, c4 int)")
+ startTime = time.time()
+ tdSql.execute("insert into t2 file 'ordered.csv'")
+ duration = time.time() - startTime
+ print("Ordered - Insert time: %d" % duration)
+ tdSql.query("select count(*) from t2")
+ tdSql.checkData(0,0, 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/insert/restfulInsert.py b/tests/pytest/insert/restfulInsert.py
index c39d1cbe48f6d08d243d39808c21741806a0ee54..da797f788fcc3cc1ae06843b70da9aaf7230e97c 100644
--- a/tests/pytest/insert/restfulInsert.py
+++ b/tests/pytest/insert/restfulInsert.py
@@ -18,10 +18,10 @@ import time
import argparse
class RestfulInsert:
- def __init__(self, host, dbname, threads, tables, records, batchSize, tbNamePerfix, outOfOrder):
+ 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 = 1500000000000
+ self.ts = startTimestamp
self.dbname = dbname
self.numOfThreads = threads
self.numOfTables = tables
@@ -29,28 +29,71 @@ class RestfulInsert:
self.batchSize = batchSize
self.tableNamePerfix = tbNamePerfix
self.outOfOrder = outOfOrder
+ self.tablePerbatch = tablePerbatch
def createTable(self, threadID):
- tablesPerThread = int (self.numOfTables / self.numOfThreads)
- print("create table %d to %d" % (tablesPerThread * threadID, tablesPerThread * (threadID + 1) - 1))
- for i in range(tablesPerThread):
+ 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 % 2 == 0 else 'shanghai'
- data = "create table %s.%s%d using %s.meters tags(%d, '%s')" % (self.dbname, self.tableNamePerfix, tableID + i, self.dbname, tableID + i, name)
- requests.post(self.url, data, headers = self.header)
+ 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)
+ response = requests.post(self.url, data, headers = self.header)
+ if response.status_code != 200:
+ print(response.content)
+
+
def insertData(self, threadID):
print("thread %d started" % threadID)
- tablesPerThread = int (self.numOfTables / self.numOfThreads)
- for i in range(tablesPerThread):
- tableID = i + threadID * tablesPerThread
- start = self.ts
- for j in range(int(self.recordsPerTable / self.batchSize)):
- data = "insert into %s.%s%d values" % (self.dbname, self.tableNamePerfix, tableID)
- values = []
- for k in range(self.batchSize):
- data += "(%d, %d, %d, %d)" % (start + j * self.batchSize + k, random.randint(1, 100), random.randint(1, 100), random.randint(1, 100))
- requests.post(self.url, data, headers = self.header)
+ 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)
+ response = requests.post(self.url, data, headers = self.header)
+ if response.status_code != 200:
+ print(response.content)
+
def insertUnlimitedData(self, threadID):
print("thread %d started" % threadID)
@@ -76,15 +119,15 @@ class RestfulInsert:
else:
random.shuffle(values)
for k in range(len(values)):
- data += values[k]
- requests.post(self.url, data, headers = self.header)
+ data += values[k]
+ response = requests.post(self.url, data, headers = self.header)
+ if response.status_code != 200:
+ print(response.content)
- def run(self):
- data = "drop database if exists %s" % self.dbname
+ def run(self):
+ data = "create database if not exists %s" % self.dbname
requests.post(self.url, data, headers = self.header)
- data = "create database %s" % self.dbname
- requests.post(self.url, data, headers = self.header)
- data = "create table %s.meters(ts timestamp, f1 int, f2 int, f3 int) tags(id int, loc nchar(20))" % self.dbname
+ 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 = []
@@ -110,7 +153,7 @@ class RestfulInsert:
for i in range(self.numOfThreads):
threads[i].join()
- print("inserting %d records takes %d seconds" % (self.numOfTables * self.recordsPerTable, (time.time() - startTime)))
+ print("inserting %s records takes %d seconds" % (self.numOfTables * self.recordsPerTable, (time.time() - startTime)))
parser = argparse.ArgumentParser()
parser.add_argument(
@@ -120,6 +163,13 @@ parser.add_argument(
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',
@@ -138,14 +188,14 @@ parser.add_argument(
'-T',
'--number-of-tables',
action='store',
- default=1000,
+ default=10000,
type=int,
help='Number of tables to be created (default: 1000)')
parser.add_argument(
'-r',
'--number-of-records',
action='store',
- default=1000,
+ default=10000,
type=int,
help='Number of record to be created for each table (default: 1000, -1 for unlimited records)')
parser.add_argument(
@@ -167,7 +217,18 @@ parser.add_argument(
'--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.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)
+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/pytest_1.sh b/tests/pytest/pytest_1.sh
new file mode 100755
index 0000000000000000000000000000000000000000..52f5a30f4e83089bc2e6f230c099e4304a94efd4
--- /dev/null
+++ b/tests/pytest/pytest_1.sh
@@ -0,0 +1,218 @@
+#!/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 insert/retentionpolicy.py
+python3 ./test.py -f insert/alterTableAndInsert.py
+python3 ./test.py -f insert/insertIntoTwoTables.py
+
+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
+
+# 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
+
+# stable
+python3 ./test.py -f stable/query_after_reset.py
+
+# table
+python3 ./test.py -f table/del_stable.py
+
+#query
+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
+
+#stream
+python3 ./test.py -f stream/metric_1.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
+
+#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
+python3 ./test.py -f client/alterDatabase.py
+
+# Misc
+python3 testCompress.py
+python3 testNoCompress.py
+python3 testMinTablesPerVnode.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_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 queryCount.py
+python3 ./test.py -f query/queryGroupbyWithInterval.py
+python3 client/twoClients.py
+python3 test.py -f query/queryInterval.py
+python3 test.py -f query/queryFillTest.py
+
+# tools
+python3 test.py -f tools/taosdemoTest.py
+python3 test.py -f tools/taosdumpTest.py
+python3 test.py -f tools/lowaTest.py
+
+# subscribe
+python3 test.py -f subscribe/singlemeter.py
+#python3 test.py -f subscribe/stability.py
+python3 test.py -f subscribe/supertable.py
+
+
diff --git a/tests/pytest/pytest_2.sh b/tests/pytest/pytest_2.sh
new file mode 100755
index 0000000000000000000000000000000000000000..fededea3bb34481aa34c37d4a802ba183494e491
--- /dev/null
+++ b/tests/pytest/pytest_2.sh
@@ -0,0 +1,17 @@
+
+
+# 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_data.py
+python3 ./test.py -f update/merge_commit_data-0.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
+
+# wal
+python3 ./test.py -f wal/addOldWalTest.py
\ 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/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
index bb92e5d9cee5baae0461cb97fd30de35acd0f5fb..080472383de905c74ca7680d2d7dddd7310daff5 100644
--- a/tests/pytest/query/bug2218.py
+++ b/tests/pytest/query/bug2218.py
@@ -38,12 +38,12 @@ class TDTestCase:
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,0.0)
- tdSql.checkData(0,2,0.0)
- tdSql.checkData(0,3,0.0)
- tdSql.checkData(0,4,0.0)
- tdSql.checkData(0,5,0.0)
- tdSql.checkData(0,6,0.0)
+ 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):
diff --git a/tests/pytest/query/queryInterval.py b/tests/pytest/query/queryInterval.py
index 98b8c9fbef819caebe34fce96bec66da99176131..871c076c0813f0ccd340d33bff992401e522df4a 100644
--- a/tests/pytest/query/queryInterval.py
+++ b/tests/pytest/query/queryInterval.py
@@ -16,6 +16,7 @@ import taos
from util.log import tdLog
from util.cases import tdCases
from util.sql import tdSql
+from util.dnodes import tdDnodes
class TDTestCase:
@@ -72,6 +73,19 @@ class TDTestCase:
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-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)
+
+
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
diff --git a/tests/pytest/query/unionAllTest.py b/tests/pytest/query/unionAllTest.py
new file mode 100644
index 0000000000000000000000000000000000000000..bb4fb95de676679d448a35b137ee8264cf802ba2
--- /dev/null
+++ b/tests/pytest/query/unionAllTest.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 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
+ 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''''
+ tdSql.query(sql)
+ tdSql.checkRows(6)
+
+ 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/taosdemoTest2.py b/tests/pytest/tools/taosdemoTest2.py
new file mode 100644
index 0000000000000000000000000000000000000000..7d5627be4363467e5e736760eea1e9f0799437d9
--- /dev/null
+++ b/tests/pytest/tools/taosdemoTest2.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 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 = 10
+ self.numberOfRecords = 1000000
+
+ def insertDataAndAlterTable(self, threadID):
+ if(threadID == 0):
+ os.system("yes | taosdemo -t %d -n %d" % (self.numberOfTables, self.numberOfRecords))
+ if(threadID == 1):
+ print("use test")
+ tdSql.execute("use test")
+ print("alter table test.meters add column f4 int")
+ tdSql.execute("alter table test.meters add column f4 int")
+ print("insert into test.t0 values (now, 1, 2, 3, 4)")
+ tdSql.execute("insert into test.t0 values (now, 1, 2, 3, 4)")
+
+ def run(self):
+ tdSql.prepare()
+
+ t1 = threading.Thread(target=self.insertDataAndAlterTable, args=(0, ))
+ t2 = threading.Thread(target=self.insertDataAndAlterTable, args=(1, ))
+
+ t1.start()
+ time.sleep(2)
+ t2.start()
+ t1.join()
+ t2.join()
+
+ 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())
\ No newline at end of file
diff --git a/tests/pytest/update/bug_td2279.py b/tests/pytest/update/bug_td2279.py
new file mode 100644
index 0000000000000000000000000000000000000000..7e8640dfa09bc904cd49fe88da29bc306fdde6d0
--- /dev/null
+++ b/tests/pytest/update/bug_td2279.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 *
+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()
+
+ 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)
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/script/basicSuite.sim b/tests/script/basicSuite.sim
index 61a9d68d2658f85256ed4c3cc62dfc53a959594b..5e22e02297bba63ec023780e425019f713dfd8d8 100644
--- a/tests/script/basicSuite.sim
+++ b/tests/script/basicSuite.sim
@@ -14,7 +14,6 @@ run general/table/vgroup.sim
run general/user/authority.sim
run general/vector/metrics_mix.sim
run general/vector/table_field.sim
-run general/user/authority.sim
run general/tag/set.sim
run general/table/delete_writing.sim
run general/stable/disk.sim
diff --git a/tests/script/general/alter/dnode.sim b/tests/script/general/alter/dnode.sim
index 20ce8799791eaf2aa6198bc07d4abde70a6f31e0..73a095ec054320d0373f137250193bc4d8230234 100644
--- a/tests/script/general/alter/dnode.sim
+++ b/tests/script/general/alter/dnode.sim
@@ -24,7 +24,7 @@ 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 monitorDebugFlag 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
@@ -44,15 +44,15 @@ sql_error alter dnode 2 tmrDebugFlag 135
print ======== step3
sql_error alter $hostname1 debugFlag 135
-sql_error alter $hostname1 monitorDebugFlag 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 monitorDebugFlag 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 monitorDebugFlag 135
+sql alter dnode $hostname1 monDebugFlag 135
sql alter dnode $hostname1 vDebugFlag 135
sql alter dnode $hostname1 tmrDebugFlag 131
diff --git a/tests/script/general/db/alter_option.sim b/tests/script/general/db/alter_option.sim
index c8aa2480c509353ede3c6ce6269afa9e6efd62b5..1c3f543ffdb149d67cfaf1527a0e88f46f626913 100644
--- a/tests/script/general/db/alter_option.sim
+++ b/tests/script/general/db/alter_option.sim
@@ -115,31 +115,31 @@ if $data7_db != 20,20,20 then
return -1
endi
-sql alter database db keep 10
+sql alter database db keep 20
sql show databases
print keep $data7_db
-if $data7_db != 20,20,10 then
+if $data7_db != 20,20,20 then
return -1
endi
-sql alter database db keep 20
+sql alter database db keep 30
sql show databases
print keep $data7_db
-if $data7_db != 20,20,20 then
+if $data7_db != 20,20,30 then
return -1
endi
-sql alter database db keep 30
+sql alter database db keep 40
sql show databases
print keep $data7_db
-if $data7_db != 20,20,30 then
+if $data7_db != 20,20,40 then
return -1
endi
sql alter database db keep 40
sql alter database db keep 30
sql alter database db keep 20
-sql alter database db keep 10
+sql_error alter database db keep 10
sql_error alter database db keep 9
sql_error alter database db keep 1
sql alter database db keep 0
@@ -277,4 +277,4 @@ 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
\ No newline at end of file
+system sh/exec.sh -n dnode1 -s stop -x SIGINT
diff --git a/tests/script/general/parser/col_arithmetic_operation.sim b/tests/script/general/parser/col_arithmetic_operation.sim
index 7adae8ef81209aefde853e4fb084b2bc74b84af4..0cc02d088b38ddb915014f306d89c65e7ff41c6c 100644
--- a/tests/script/general/parser/col_arithmetic_operation.sim
+++ b/tests/script/general/parser/col_arithmetic_operation.sim
@@ -117,16 +117,17 @@ run general/parser/col_arithmetic_query.sim
# ================================================================================================
print ====================> crash
-# sql select spread(ts )/(1000*3600*24) from ca_stb0 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 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
diff --git a/tests/script/general/parser/col_arithmetic_query.sim b/tests/script/general/parser/col_arithmetic_query.sim
index 408b039144e1f3de16b2f58fc34b18b39ed9e5e6..53e2c98b56e3c395e810e9edbb1d094baaa20f5c 100644
--- a/tests/script/general/parser/col_arithmetic_query.sim
+++ b/tests/script/general/parser/col_arithmetic_query.sim
@@ -62,24 +62,73 @@ if $data91 != 1.000000000 then
return -1
endi
-sql select (c1 * 2) % 7.9 from $tb order by ts desc;
+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 != 0.100000000 then
- print expect 0.100000000, acutal:$data00
+if $data00 != 2.200000000 then
+ print expect 2.200000000, actual:$data00
return -1
endi
-if $data10 != 2.100000000 then
+if $data01 != 9.000000000 then
return -1
endi
-if $data90 != 6.000000000 then
+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
@@ -95,7 +144,7 @@ if $data10 != 16.000000000 then
endi
if $data20 != 20.250000000 then
- print expect 20.250000000, acutal:$data21
+ print expect 20.250000000, actual:$data21
return -1
endi
@@ -320,7 +369,9 @@ sql_error select c7-c9 from $tb interval(2y)
# multiple retrieve [d.20]===============================================================
sql select c2-c2, 911 from $tb
-#======================================= aggregation function arithmetic query cases ================
+#======================================= 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
@@ -349,11 +400,11 @@ if $data00 != 1.800000000 then
return -1
endi
-if $data01 != 100000 then
+if $data01 != 100000.000000000 then
return -1
endi
-if $data02 != 200000 then
+if $data02 != 200000.000000000 then
return -1
endi
@@ -374,77 +425,192 @@ if $data02 != 9.000000020 then
return -1
endi
-# all possible function in the arithmetic expressioin
-sql select min(c1) * max(c2) /4, sum(c1) * percentile(c2, 20), apercentile(c4, 33) + 52/9, spread(c5)/min(c2) from $stb where ts < and ts >
+# 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:00.000';
+if $rows != 1 then
+ return -1
+endi
-# no result return [d.3]
+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 != inf 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 $tb where ts>xxx
+sql select sum(c2) - avg(c2) from $stb where ts > '2018-11-25 19:30:00.000'
if $rows != 0 then
return -1
endi
-# single row result aggregation [d.4]
-sql select
+# 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 $tb
+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 select top(c1, 1) - bottom(c1, 1) from $tb
-sql select top(c1, 99) - bottom(c1, 99) from $tb
+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 $tb
+# 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 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 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 join [d.7]===============================================================
-# arithmetic expression in union [d.8]
+# arithmetic expression in union [d.8]===============================================================
-# arithmetic expression in group by [d.9]
+# 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
+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_error select c6-c6+c3*12 from $tb group by c3;
+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
-sql select first(c6) - last(c6) *12 / count(*) from $tb group by c3;
+if $data01 != 0.000000000 then
+ return -1
+endi
-# limit offset [d.10]
-sql select c6-c6+12 from $tb limit 12 offset 99;
-sql select c4/99.123 from $tb limit 1 offset 9999;
+if $data10 != 12.000000000 then
+ return -1
+endi
-# slimit/soffset not suport for normal table query. [d.11]
-sql_error select sum(c1) from $tb slimit 1 soffset 19;
+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 != 10 then
+ return -1
+endi
+
+if $data00 != 0.000000000 then
+ return -1
+endi
+
+if $data10 != 0.997600000 then
+ return -1
+endi
+
+if $data90 != 8.978400000 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
-# fill [d.12]
-sql_error select c2-c2, c3-c4, c5%c6 from $tb fill(value, 12);
+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
-# constant column. [d.13]
+# 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]
+# column value filter [d.14]===============================================================
-# tag filter(not support for normal table). [d.15]
-sql_error select sum(c2)+99 from $tb where t1=12;
-# multi-field output [d.16]
+# 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
@@ -461,18 +627,30 @@ 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)
+# 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
-# aggregation query [d.18]
-# see test cases below
+if $data00 != @18-09-17 09:00:00.000@ then
+ return -1
+endi
-# first/last query [d.19]
-# see test cases below
+sql_error select first(c7)- last(c1) from $tb interval(2y)
-# multiple retrieve [d.20]
-sql select c2-c2 from $tb;
+# 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/first_last.sim b/tests/script/general/parser/first_last.sim
index a934d3bcabf09ebe1584c296d6cab2f5c80654d2..773f92afcfd1fb126f137befd9de1107b050356f 100644
--- a/tests/script/general/parser/first_last.sim
+++ b/tests/script/general/parser/first_last.sim
@@ -46,7 +46,8 @@ while $i < $tbNum
endw
$i = $i + 1
-endw
+endw
+
$ts = $ts + 60000
$tb = $tbPrefix . 0
sql insert into $tb (ts) values ( $ts )
@@ -84,4 +85,43 @@ sleep 500
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 3000
+system sh/exec.sh -n dnode1 -s start
+print ================== server restart completed
+sql connect
+sleep 500
+
+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
\ No newline at end of file
diff --git a/tests/script/general/parser/first_last_query.sim b/tests/script/general/parser/first_last_query.sim
index a982f10362a46e7c671e8df4674b06c5c9f60b75..52d888b04d1b055bbbc3c8509832c96579e4320f 100644
--- a/tests/script/general/parser/first_last_query.sim
+++ b/tests/script/general/parser/first_last_query.sim
@@ -266,4 +266,6 @@ endi
if $data14 != @test2@ then
print expect test2 , actual: $data14
return -1
-endi
\ No newline at end of file
+endi
+
+sql drop table stest
\ 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..34e9844f711313d9f7c1c2380177bfc2c7aa4740
--- /dev/null
+++ b/tests/script/general/parser/function.sim
@@ -0,0 +1,228 @@
+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 tableMetaKeepTimer -v 3
+system sh/exec.sh -n dnode1 -s start
+sleep 500
+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
+sql use $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.00@ 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),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 filte exists.
+
+select count(*),TWA(k) from tm0 where ts>='1970-1-1 13:43:00' and ts<='1970-1-1 13:44:10' interval(9s)
diff --git a/tests/script/general/parser/groupby.sim b/tests/script/general/parser/groupby.sim
index 19d9ae84cbc02e179c2ab060082507529b2bb608..44bae6f242f12e5a6430df64520631d0ac3af073 100644
--- a/tests/script/general/parser/groupby.sim
+++ b/tests/script/general/parser/groupby.sim
@@ -606,6 +606,44 @@ sql insert into t1 values ('2020-03-27 04:21:16.000', 1)('2020-03-27 04:31:17.00
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-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
+
#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
diff --git a/tests/script/general/parser/limit.sim b/tests/script/general/parser/limit.sim
index fb5e704bf1ba3bab457dae2dc06a23628fde316c..2089cd3d2af96e95a910acaf1067b90aa40c26be 100644
--- a/tests/script/general/parser/limit.sim
+++ b/tests/script/general/parser/limit.sim
@@ -48,8 +48,12 @@ while $i < $halfNum
$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 )
+
+ $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
diff --git a/tests/script/general/parser/limit1_stb.sim b/tests/script/general/parser/limit1_stb.sim
index d5846adc45327e6faa7b2bd7cdd10b44ea6fc094..7d61a826aa90c8dd5b3a62de1e9688c0278f59fd 100644
--- a/tests/script/general/parser/limit1_stb.sim
+++ b/tests/script/general/parser/limit1_stb.sim
@@ -94,66 +94,66 @@ 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
+#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
@@ -163,6 +163,7 @@ 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
@@ -255,102 +256,102 @@ 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
+#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
+#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
+#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
diff --git a/tests/script/general/parser/limit1_tb.sim b/tests/script/general/parser/limit1_tb.sim
index 1e473eb8580965b6e777c7fe09cbc607af8938a8..72b63256dba36c799e308b41bebb4a53d5d64334 100644
--- a/tests/script/general/parser/limit1_tb.sim
+++ b/tests/script/general/parser/limit1_tb.sim
@@ -703,13 +703,13 @@ sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where t
if $rows != 1 then
return -1
endi
-if $data00 != 4.499549955 then
+if $data00 != 4.500000000 then
return -1
endi
-if $data02 != 4.499549955 then
+if $data02 != 4.500000000 then
return -1
endi
-if $data05 != 4.499549955 then
+if $data05 != 4.500000000 then
return -1
endi
@@ -717,10 +717,12 @@ sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from
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
@@ -731,7 +733,6 @@ 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
diff --git a/tests/script/general/parser/limit_stb.sim b/tests/script/general/parser/limit_stb.sim
index b41b7b726bc24b83f64cecbec8ac0eb83afa57ea..d929810817927572eb7e1929ce5d98cde0940916 100644
--- a/tests/script/general/parser/limit_stb.sim
+++ b/tests/script/general/parser/limit_stb.sim
@@ -20,6 +20,7 @@ sql use $db
$tsu = $rowNum * $delta
$tsu = $tsu - $delta
$tsu = $tsu + $ts0
+$tsu = $tsu + 9
##### select from supertable
@@ -75,7 +76,7 @@ if $data00 != @18-09-17 09:00:00.000@ then
return -1
endi
-if $data40 != @18-09-17 09:00:00.000@ then
+if $data40 != @18-09-17 09:00:00.004@ then
return -1
endi
@@ -84,11 +85,11 @@ if $data01 != 0 then
endi
print data12 = $data12
-if $data12 != NULL then
+if $data12 != 0 then
return -1
endi
-if $data24 != NULL then
+if $data24 != 0.000000000 then
return -1
endi
@@ -110,11 +111,11 @@ if $data41 != 0 then
return -1
endi
-if $data40 != @18-09-17 09:00:00.000@ then
+if $data40 != @18-09-17 09:00:00.005@ then
return -1
endi
-if $data00 != @18-09-17 09:00:00.000@ then
+if $data00 != @18-09-17 09:00:00.001@ then
return -1
endi
@@ -123,20 +124,13 @@ if $rows != 99 then
return -1
endi
-if $data01 != 1 then
- return -1
-endi
-if $data41 != 5 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.000@ then
+if $data00 != @18-09-17 10:30:00.009@ then
return -1
endi
if $data01 != 9 then
@@ -174,7 +168,7 @@ sql select * from $stb limit 2 offset $offset
if $rows != 2 then
return -1
endi
-if $data00 != @18-09-17 10:30:00.000@ then
+if $data00 != @18-09-17 10:30:00.002@ then
return -1
endi
if $data01 != 9 then
@@ -204,36 +198,36 @@ 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
+#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
@@ -248,6 +242,7 @@ 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
@@ -288,52 +283,52 @@ if $data09 != nchar4 then
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
+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 != 5 then
+if $data01 != 3 then
return -1
endi
-if $data11 != 6 then
+if $data11 != 3 then
return -1
endi
-if $data21 != 7 then
+if $data21 != 3 then
return -1
endi
-if $data31 != 8 then
+if $data31 != 3 then
return -1
endi
-if $data41 != 4 then
+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:30:00.000' limit 5 offset 50
+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' limit 5 offset 1
+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 != 5 then
+if $data01 != 3 then
return -1
endi
-if $data11 != 6 then
+if $data11 != 3 then
return -1
endi
-if $data21 != 7 then
+if $data21 != 3 then
return -1
endi
-if $data31 != 8 then
+if $data31 != 3 then
return -1
endi
-if $data41 != 4 then
+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.000' 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.009' order by ts asc limit 1 offset 0;
if $rows != 1 then
return -1
endi
@@ -842,9 +837,6 @@ sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts desc
if $rows != 3 then
return -1
endi
-if $data00 != @18-09-17 10:30:00.000@ then
- return -1
-endi
if $data01 != 9 then
return -1
endi
@@ -853,9 +845,6 @@ sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc
if $rows != 3 then
return -1
endi
-if $data00 != @18-09-17 10:30:00.000@ then
- return -1
-endi
if $data01 != 9 then
return -1
endi
@@ -864,7 +853,7 @@ sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 orde
if $rows != 6 then
return -1
endi
-if $data00 != @18-09-17 10:00:00.000@ then
+if $data00 != @18-09-17 10:00:00.008@ then
return -1
endi
if $data01 != 6 then
@@ -873,7 +862,7 @@ endi
if $data02 != 8 then
return -1
endi
-if $data10 != @18-09-17 10:10:00.000@ then
+if $data10 != @18-09-17 10:10:00.008@ then
return -1
endi
if $data11 != 7 then
@@ -882,7 +871,7 @@ endi
if $data12 != 8 then
return -1
endi
-if $data20 != @18-09-17 10:20:00.000@ then
+if $data20 != @18-09-17 10:20:00.008@ then
return -1
endi
if $data21 != 8 then
@@ -891,7 +880,7 @@ endi
if $data22 != 8 then
return -1
endi
-if $data30 != @18-09-17 10:00:00.000@ then
+if $data30 != @18-09-17 10:00:00.007@ then
return -1
endi
if $data31 != 6 then
@@ -900,7 +889,7 @@ endi
if $data32 != 7 then
return -1
endi
-if $data40 != @18-09-17 10:10:00.000@ then
+if $data40 != @18-09-17 10:10:00.007@ then
return -1
endi
if $data41 != 7 then
@@ -909,7 +898,7 @@ endi
if $data42 != 7 then
return -1
endi
-if $data50 != @18-09-17 10:20:00.000@ then
+if $data50 != @18-09-17 10:20:00.007@ then
return -1
endi
if $data51 != 8 then
@@ -923,7 +912,7 @@ sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 orde
if $rows != 6 then
return -1
endi
-if $data00 != @18-09-17 10:00:00.000@ then
+if $data00 != @18-09-17 10:00:00.001@ then
return -1
endi
if $data01 != 6 then
@@ -932,7 +921,7 @@ endi
if $data02 != 1 then
return -1
endi
-if $data10 != @18-09-17 10:10:00.000@ then
+if $data10 != @18-09-17 10:10:00.001@ then
return -1
endi
if $data11 != 7 then
@@ -941,7 +930,7 @@ endi
if $data12 != 1 then
return -1
endi
-if $data20 != @18-09-17 10:20:00.000@ then
+if $data20 != @18-09-17 10:20:00.001@ then
return -1
endi
if $data21 != 8 then
@@ -950,7 +939,7 @@ endi
if $data22 != 1 then
return -1
endi
-if $data30 != @18-09-17 10:00:00.000@ then
+if $data30 != @18-09-17 10:00:00.002@ then
return -1
endi
if $data31 != 6 then
@@ -959,7 +948,7 @@ endi
if $data32 != 2 then
return -1
endi
-if $data40 != @18-09-17 10:10:00.000@ then
+if $data40 != @18-09-17 10:10:00.002@ then
return -1
endi
if $data41 != 7 then
@@ -968,7 +957,7 @@ endi
if $data42 != 2 then
return -1
endi
-if $data50 != @18-09-17 10:20:00.000@ then
+if $data50 != @18-09-17 10:20:00.002@ then
return -1
endi
if $data51 != 8 then
@@ -982,7 +971,7 @@ sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 orde
if $rows != 6 then
return -1
endi
-if $data00 != @18-09-17 10:20:00.000@ then
+if $data00 != @18-09-17 10:20:00.001@ then
return -1
endi
if $data01 != 8 then
@@ -991,7 +980,7 @@ endi
if $data02 != 1 then
return -1
endi
-if $data10 != @18-09-17 10:10:00.000@ then
+if $data10 != @18-09-17 10:10:00.001@ then
return -1
endi
if $data11 != 7 then
@@ -1000,7 +989,7 @@ endi
if $data12 != 1 then
return -1
endi
-if $data20 != @18-09-17 10:00:00.000@ then
+if $data20 != @18-09-17 10:00:00.001@ then
return -1
endi
if $data21 != 6 then
@@ -1009,7 +998,7 @@ endi
if $data22 != 1 then
return -1
endi
-if $data30 != @18-09-17 10:20:00.000@ then
+if $data30 != @18-09-17 10:20:00.002@ then
return -1
endi
if $data31 != 8 then
@@ -1018,7 +1007,7 @@ endi
if $data32 != 2 then
return -1
endi
-if $data40 != @18-09-17 10:10:00.000@ then
+if $data40 != @18-09-17 10:10:00.002@ then
return -1
endi
if $data41 != 7 then
@@ -1027,7 +1016,7 @@ endi
if $data42 != 2 then
return -1
endi
-if $data50 != @18-09-17 10:00:00.000@ then
+if $data50 != @18-09-17 10:00:00.002@ then
return -1
endi
if $data51 != 6 then
@@ -1052,9 +1041,9 @@ sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts d
if $rows != 3 then
return -1
endi
-if $data00 != @18-09-17 09:00:00.000@ then
- return -1
-endi
+#if $data00 != @18-09-17 09:00:00.000@ then
+# return -1
+#endi
if $data01 != 0 then
return -1
endi
@@ -1063,9 +1052,9 @@ sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts a
if $rows != 3 then
return -1
endi
-if $data00 != @18-09-17 09:00:00.000@ then
- return -1
-endi
+#if $data00 != @18-09-17 09:00:00.000@ then
+# return -1
+#endi
if $data01 != 0 then
return -1
endi
@@ -1074,54 +1063,54 @@ sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 o
if $rows != 6 then
return -1
endi
-if $data00 != @18-09-17 09:30:00.000@ 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 $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 $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 $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 $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 $data50 != @18-09-17 09:10:00.000@ then
+# return -1
+#endi
if $data51 != 1 then
return -1
endi
@@ -1133,54 +1122,54 @@ sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 o
if $rows != 6 then
return -1
endi
-if $data00 != @18-09-17 09:30:00.000@ 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 $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 $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 $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 $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 $data50 != @18-09-17 09:10:00.000@ then
+# return -1
+#endi
if $data51 != 1 then
return -1
endi
@@ -1192,54 +1181,54 @@ sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 o
if $rows != 6 then
return -1
endi
-if $data00 != @18-09-17 09:30:00.000@ 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 $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 $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 $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 $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 $data50 != @18-09-17 09:10:00.000@ then
+# return -1
+#endi
if $data51 != 1 then
return -1
endi
diff --git a/tests/script/general/parser/limit_tb.sim b/tests/script/general/parser/limit_tb.sim
index b917627fdf6499fe2dacf948af7badb2b5de43d7..45f55412086c2155a2c7c924603c60d5081a643f 100644
--- a/tests/script/general/parser/limit_tb.sim
+++ b/tests/script/general/parser/limit_tb.sim
@@ -327,22 +327,22 @@ sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where t
if $rows != 1 then
return -1
endi
-if $data00 != 4.000000000 then
+if $data00 != 4.500000000 then
return -1
endi
-if $data01 != 4.000000000 then
+if $data01 != 4.500000000 then
return -1
endi
-if $data02 != 4.000000000 then
+if $data02 != 4.500000000 then
return -1
endi
-if $data03 != 4.000000000 then
+if $data03 != 4.500000000 then
return -1
endi
-if $data04 != 4.000000000 then
+if $data04 != 4.500000000 then
return -1
endi
-if $data05 != 4.000000000 then
+if $data05 != 4.500000000 then
return -1
endi
@@ -690,13 +690,13 @@ sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where t
if $rows != 1 then
return -1
endi
-if $data00 != 4.000000000 then
+if $data00 != 4.500000000 then
return -1
endi
-if $data02 != 4.000000000 then
+if $data02 != 4.500000000 then
return -1
endi
-if $data05 != 4.000000000 then
+if $data05 != 4.500000000 then
return -1
endi
diff --git a/tests/script/general/parser/where.sim b/tests/script/general/parser/where.sim
index 8e17220b5b38f995c6dc7e662130f7250157aa44..c5b600b514be8047ab0292f23d69c9ddd6ef8399 100644
--- a/tests/script/general/parser/where.sim
+++ b/tests/script/general/parser/where.sim
@@ -131,7 +131,6 @@ 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
@@ -178,7 +177,8 @@ sql create table wh_mt2_tb1 using wh_mt2 tags ('wh_mt2_tb1')
# 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 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
diff --git a/tests/script/general/stable/values.sim b/tests/script/general/stable/values.sim
index d0c178385103f8fb719ed8d7ec35f55bd9023d22..51488aabef8918b957ca63fd29823b14f772b675 100644
--- a/tests/script/general/stable/values.sim
+++ b/tests/script/general/stable/values.sim
@@ -18,16 +18,25 @@ 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.vtb10 using vdb0.mt tags( 1 )
-sql create table vdb1.vtb11 using vdb0.mt tags( 1 )
+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.vtb20 using vdb0.mt tags( 2 )
-sql create table vdb2.vtb21 using vdb0.mt tags( 2 )
+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.vtb30 using vdb0.mt tags( 3 )
-sql create table vdb3.vtb31 using vdb0.mt tags( 3 )
+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)
@@ -40,7 +49,7 @@ sql insert into vdb3.vtb30 values (1519833600000 , 13) (1519833600001, 23) (1519
sql insert into vdb3.vtb31 values (1519833600000 , 13) (1519833600001, 23) (1519833600002, 33)
sql select * from vdb0.mt
-if $rows != 24 then
+if $rows != 6 then
return -1
endi
@@ -55,7 +64,7 @@ sql insert into vdb3.vtb30 values (1519833600003 , 43) (1519833600005, 53) (1519
sql insert into vdb3.vtb31 values (1519833600003 , 43) (1519833600005, 53) (1519833600004, 63)
sql select * from vdb0.mt
-if $rows != 48 then
+if $rows != 12 then
return -1
endi
@@ -66,7 +75,7 @@ sql insert into vdb2.vtb20 values(1519833600006, 62) (1519833600007, 72) vdb2.vt
sql insert into vdb3.vtb30 values(1519833600006, 63) (1519833600007, 73) vdb3.vtb31 values(1519833600006, 63) (1519833600007, 73)
sql select * from vdb0.mt
-if $rows != 64 then
+if $rows != 16 then
return -1
endi
@@ -77,7 +86,7 @@ sql insert into vdb2.vtb20 values(1519833600008, 82) (1519833600007, 72) vdb2.vt
sql insert into vdb3.vtb30 values(1519833600008, 83) (1519833600007, 73) vdb3.vtb31 values(1519833600006, 83) (1519833600007, 73)
sql select * from vdb0.mt
-if $rows != 68 then
+if $rows != 17 then
return -1
endi
@@ -87,7 +96,7 @@ sql insert into vdb0.vtb01 values(1519833600009, 90) (1519833600010, 100) vdb1.v
sql select * from vdb0.mt
-if $rows != 84 then
+if $rows != 21 then
return -1
endi
@@ -97,7 +106,7 @@ sql insert into vdb0.vtb01 values(1519833600012, 120) (1519833600011, 110) vdb1.
sql select * from vdb0.mt
-if $rows != 100 then
+if $rows != 25 then
return -1
endi
diff --git a/tests/script/general/wal/sync.sim b/tests/script/general/wal/sync.sim
index abaf22f91921e5bcc8effbe6fc1c66766ff92a3f..c6f7402b874115811e6422894c612c341ea5256f 100644
--- a/tests/script/general/wal/sync.sim
+++ b/tests/script/general/wal/sync.sim
@@ -82,6 +82,7 @@ restful d1 table_rest 1591772800 30000
restful d1 table_rest 1591872800 30000
restful d1 table_rest 1591972800 30000
+sleep 1000
sql select * from table_rest;
print rows: $rows
if $rows != 300000 then
diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh
index e26778e86b9876ab6e6f47f4b41207ea35cafbf5..cd2f3772eb11a0c5d3a7a69fcb3d62162eadf14c 100755
--- a/tests/script/sh/deploy.sh
+++ b/tests/script/sh/deploy.sh
@@ -120,7 +120,7 @@ echo "cDebugFlag 143" >> $TAOS_CFG
echo "jnidebugFlag 143" >> $TAOS_CFG
echo "odbcdebugFlag 143" >> $TAOS_CFG
echo "httpDebugFlag 143" >> $TAOS_CFG
-echo "monitorDebugFlag 143" >> $TAOS_CFG
+echo "monDebugFlag 143" >> $TAOS_CFG
echo "mqttDebugFlag 143" >> $TAOS_CFG
echo "qdebugFlag 143" >> $TAOS_CFG
echo "rpcDebugFlag 143" >> $TAOS_CFG
diff --git a/tests/script/tmp/mnodes.sim b/tests/script/tmp/mnodes.sim
index de02ae741b75d4764f280d4aca5eb9cb139aa7ff..e11140028d474b131c472d6c0ff0f9a56587e3a9 100644
--- a/tests/script/tmp/mnodes.sim
+++ b/tests/script/tmp/mnodes.sim
@@ -20,6 +20,10 @@ 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
diff --git a/tests/test-all.sh b/tests/test-all.sh
index 5897978bce6ab68255b07dd85b3c310526e90e15..14b649eddfe92e8c557f81d27a0d1b95b35602c3 100755
--- a/tests/test-all.sh
+++ b/tests/test-all.sh
@@ -137,6 +137,12 @@ if [ "$2" != "sim" ]; then
elif [ "$1" == "pytest" ]; then
echo "### run Python full test ###"
runPyCaseOneByOne fulltest.sh
+ elif [ "$1" == "p1" ]; then
+ echo "### run Python_1 test ###"
+ runPyCaseOneByOne pytest_1.sh
+ elif [ "$1" == "p2" ]; then
+ echo "### run Python_2 test ###"
+ runPyCaseOneByOne pytest_2.sh
elif [ "$1" == "b2" ] || [ "$1" == "b3" ]; then
exit $(($totalFailed + $totalPyFailed))
elif [ "$1" == "smoke" ] || [ -z "$1" ]; then
diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt
index 26aa20e647cc166ac991e64bc18511e9b504b335..11480a8ba2f7c2a78b8628e3edabe6e0eb122410 100644
--- a/tests/test/c/CMakeLists.txt
+++ b/tests/test/c/CMakeLists.txt
@@ -31,8 +31,8 @@ IF (TD_LINUX)
#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(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)
@@ -45,5 +45,8 @@ IF (TD_LINUX)
#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/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