[TD-225]
This commit is contained in:
parent
cb5bc95969
commit
b8ffb3b047
|
@ -361,7 +361,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
|
|||
memcpy(pRes->pRsp, rpcMsg->pCont, pRes->rspLen);
|
||||
}
|
||||
} else {
|
||||
taosTFree(pRes->pRsp);
|
||||
tfree(pRes->pRsp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -9,26 +9,40 @@
|
|||
|
||||
|
||||
static void prepare_data(TAOS* taos) {
|
||||
taos_query(taos, "drop database if exists test;");
|
||||
TAOS_RES *result;
|
||||
result = taos_query(taos, "drop database if exists test;");
|
||||
taos_free_result(result);
|
||||
usleep(100000);
|
||||
taos_query(taos, "create database test;");
|
||||
result = taos_query(taos, "create database test;");
|
||||
taos_free_result(result);
|
||||
usleep(100000);
|
||||
taos_select_db(taos, "test");
|
||||
|
||||
taos_query(taos, "create table meters(ts timestamp, a int) tags(area int);");
|
||||
result = taos_query(taos, "create table meters(ts timestamp, a int) tags(area int);");
|
||||
taos_free_result(result);
|
||||
|
||||
taos_query(taos, "create table t0 using meters tags(0);");
|
||||
taos_query(taos, "create table t1 using meters tags(1);");
|
||||
taos_query(taos, "create table t2 using meters tags(2);");
|
||||
taos_query(taos, "create table t3 using meters tags(3);");
|
||||
taos_query(taos, "create table t4 using meters tags(4);");
|
||||
taos_query(taos, "create table t5 using meters tags(5);");
|
||||
taos_query(taos, "create table t6 using meters tags(6);");
|
||||
taos_query(taos, "create table t7 using meters tags(7);");
|
||||
taos_query(taos, "create table t8 using meters tags(8);");
|
||||
taos_query(taos, "create table t9 using meters tags(9);");
|
||||
result = taos_query(taos, "create table t0 using meters tags(0);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t1 using meters tags(1);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t2 using meters tags(2);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t3 using meters tags(3);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t4 using meters tags(4);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t5 using meters tags(5);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t6 using meters tags(6);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t7 using meters tags(7);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t8 using meters tags(8);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "create table t9 using meters tags(9);");
|
||||
taos_free_result(result);
|
||||
|
||||
TAOS_RES* res = taos_query(taos, "insert into t0 values('2020-01-01 00:00:00.000', 0)"
|
||||
result = taos_query(taos, "insert into t0 values('2020-01-01 00:00:00.000', 0)"
|
||||
" ('2020-01-01 00:01:00.000', 0)"
|
||||
" ('2020-01-01 00:02:00.000', 0)"
|
||||
" t1 values('2020-01-01 00:00:00.000', 0)"
|
||||
|
@ -46,10 +60,11 @@ static void prepare_data(TAOS* taos) {
|
|||
" t7 values('2020-01-01 00:01:02.000', 0)"
|
||||
" t8 values('2020-01-01 00:01:02.000', 0)"
|
||||
" t9 values('2020-01-01 00:01:02.000', 0)");
|
||||
int affected = taos_affected_rows(res);
|
||||
int affected = taos_affected_rows(result);
|
||||
if (affected != 18) {
|
||||
printf("\033[31m%d rows affected by last insert statement, but it should be 18\033[0m\n", affected);
|
||||
}
|
||||
taos_free_result(result);
|
||||
// super tables subscription
|
||||
usleep(1000000);
|
||||
}
|
||||
|
@ -135,6 +150,7 @@ static void verify_query(TAOS* taos) {
|
|||
|
||||
res = taos_query(taos, "select * from meters");
|
||||
taos_stop_query(res);
|
||||
taos_free_result(res);
|
||||
}
|
||||
|
||||
|
||||
|
@ -153,23 +169,30 @@ static void verify_subscribe(TAOS* taos) {
|
|||
res = taos_consume(tsub);
|
||||
check_row_count(__LINE__, res, 0);
|
||||
|
||||
taos_query(taos, "insert into t0 values('2020-01-01 00:02:00.001', 0);");
|
||||
taos_query(taos, "insert into t8 values('2020-01-01 00:01:03.000', 0);");
|
||||
TAOS_RES *result;
|
||||
result = taos_query(taos, "insert into t0 values('2020-01-01 00:02:00.001', 0);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "insert into t8 values('2020-01-01 00:01:03.000', 0);");
|
||||
taos_free_result(result);
|
||||
res = taos_consume(tsub);
|
||||
check_row_count(__LINE__, res, 2);
|
||||
|
||||
taos_query(taos, "insert into t2 values('2020-01-01 00:01:02.001', 0);");
|
||||
taos_query(taos, "insert into t1 values('2020-01-01 00:03:00.001', 0);");
|
||||
result = taos_query(taos, "insert into t2 values('2020-01-01 00:01:02.001', 0);");
|
||||
taos_free_result(result);
|
||||
result = taos_query(taos, "insert into t1 values('2020-01-01 00:03:00.001', 0);");
|
||||
taos_free_result(result);
|
||||
res = taos_consume(tsub);
|
||||
check_row_count(__LINE__, res, 2);
|
||||
|
||||
taos_query(taos, "insert into t1 values('2020-01-01 00:03:00.002', 0);");
|
||||
result = taos_query(taos, "insert into t1 values('2020-01-01 00:03:00.002', 0);");
|
||||
taos_free_result(result);
|
||||
res = taos_consume(tsub);
|
||||
check_row_count(__LINE__, res, 1);
|
||||
|
||||
// keep progress information and restart subscription
|
||||
taos_unsubscribe(tsub, 1);
|
||||
taos_query(taos, "insert into t0 values('2020-01-01 00:04:00.000', 0);");
|
||||
result = taos_query(taos, "insert into t0 values('2020-01-01 00:04:00.000', 0);");
|
||||
taos_free_result(result);
|
||||
tsub = taos_subscribe(taos, 1, "test", "select * from meters;", NULL, NULL, 0);
|
||||
res = taos_consume(tsub);
|
||||
check_row_count(__LINE__, res, 24);
|
||||
|
@ -196,7 +219,8 @@ static void verify_subscribe(TAOS* taos) {
|
|||
res = taos_consume(tsub);
|
||||
check_row_count(__LINE__, res, 0);
|
||||
|
||||
taos_query(taos, "insert into t0 values('2020-01-01 00:04:00.001', 0);");
|
||||
result = taos_query(taos, "insert into t0 values('2020-01-01 00:04:00.001', 0);");
|
||||
taos_free_result(result);
|
||||
res = taos_consume(tsub);
|
||||
check_row_count(__LINE__, res, 1);
|
||||
|
||||
|
@ -205,7 +229,8 @@ static void verify_subscribe(TAOS* taos) {
|
|||
int blockFetch = 0;
|
||||
tsub = taos_subscribe(taos, 1, "test", "select * from meters;", subscribe_callback, &blockFetch, 1000);
|
||||
usleep(2000000);
|
||||
taos_query(taos, "insert into t0 values('2020-01-01 00:05:00.001', 0);");
|
||||
result = taos_query(taos, "insert into t0 values('2020-01-01 00:05:00.001', 0);");
|
||||
taos_free_result(result);
|
||||
usleep(2000000);
|
||||
taos_unsubscribe(tsub, 0);
|
||||
}
|
||||
|
@ -213,8 +238,9 @@ static void verify_subscribe(TAOS* taos) {
|
|||
|
||||
void verify_prepare(TAOS* taos) {
|
||||
TAOS_RES* result = taos_query(taos, "drop database if exists test;");
|
||||
taos_free_result(result);
|
||||
usleep(100000);
|
||||
taos_query(taos, "create database test;");
|
||||
result = taos_query(taos, "create database test;");
|
||||
|
||||
int code = taos_errno(result);
|
||||
if (code != 0) {
|
||||
|
@ -429,7 +455,8 @@ void verify_stream(TAOS* taos) {
|
|||
NULL);
|
||||
printf("waiting for stream data\n");
|
||||
usleep(100000);
|
||||
taos_query(taos, "insert into t0 values(now, 0)(now+5s,1)(now+10s, 2);");
|
||||
TAOS_RES* result = taos_query(taos, "insert into t0 values(now, 0)(now+5s,1)(now+10s, 2);");
|
||||
taos_free_result(result);
|
||||
usleep(200000000);
|
||||
taos_close_stream(strm);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,34 @@ void taos_insert_call_back(void *param, TAOS_RES *tres, int code);
|
|||
void taos_select_call_back(void *param, TAOS_RES *tres, int code);
|
||||
void taos_error(TAOS *taos);
|
||||
|
||||
static void queryDB(TAOS *taos, char *command) {
|
||||
int i;
|
||||
TAOS_RES *pSql = NULL;
|
||||
int32_t code = -1;
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
if (NULL != pSql) {
|
||||
taos_free_result(pSql);
|
||||
pSql = NULL;
|
||||
}
|
||||
|
||||
pSql = taos_query(taos, command);
|
||||
code = taos_errno(pSql);
|
||||
if (0 == code) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (code != 0) {
|
||||
fprintf(stderr, "Failed to run %s, reason: %s\n", command, taos_errstr(pSql));
|
||||
taos_free_result(pSql);
|
||||
taos_close(taos);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
taos_free_result(pSql);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
TAOS *taos;
|
||||
|
@ -78,16 +106,14 @@ int main(int argc, char *argv[])
|
|||
|
||||
printf("success to connect to server\n");
|
||||
|
||||
sprintf(sql, "drop database %s", db);
|
||||
taos_query(taos, sql);
|
||||
sprintf(sql, "drop database if exists %s", db);
|
||||
queryDB(taos, sql);
|
||||
|
||||
sprintf(sql, "create database %s", db);
|
||||
if (taos_query(taos, sql) != 0)
|
||||
taos_error(taos);
|
||||
queryDB(taos, sql);
|
||||
|
||||
sprintf(sql, "use %s", db);
|
||||
if (taos_query(taos, sql) != 0)
|
||||
taos_error(taos);
|
||||
queryDB(taos, sql);
|
||||
|
||||
strcpy(prefix, "asytbl_");
|
||||
for (i = 0; i < numOfTables; ++i) {
|
||||
|
@ -95,8 +121,7 @@ int main(int argc, char *argv[])
|
|||
tableList[i].taos = taos;
|
||||
sprintf(tableList[i].name, "%s%d", prefix, i);
|
||||
sprintf(sql, "create table %s%d (ts timestamp, volume bigint)", prefix, i);
|
||||
if (taos_query(taos, sql) != 0)
|
||||
taos_error(taos);
|
||||
queryDB(taos, sql);
|
||||
}
|
||||
|
||||
gettimeofday(&systemTime, NULL);
|
||||
|
|
|
@ -22,6 +22,34 @@
|
|||
#include <inttypes.h>
|
||||
#include <taos.h> // TAOS header file
|
||||
|
||||
static void queryDB(TAOS *taos, char *command) {
|
||||
int i;
|
||||
TAOS_RES *pSql = NULL;
|
||||
int32_t code = -1;
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
if (NULL != pSql) {
|
||||
taos_free_result(pSql);
|
||||
pSql = NULL;
|
||||
}
|
||||
|
||||
pSql = taos_query(taos, command);
|
||||
code = taos_errno(pSql);
|
||||
if (0 == code) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (code != 0) {
|
||||
fprintf(stderr, "Failed to run %s, reason: %s\n", command, taos_errstr(pSql));
|
||||
taos_free_result(pSql);
|
||||
taos_close(taos);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
taos_free_result(pSql);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
TAOS * taos;
|
||||
char qstr[1024];
|
||||
|
@ -44,22 +72,26 @@ int main(int argc, char *argv[]) {
|
|||
printf("success to connect to server\n");
|
||||
|
||||
|
||||
taos_query(taos, "drop database demo");
|
||||
//taos_query(taos, "drop database demo");
|
||||
queryDB(taos, "drop database if exists demo");
|
||||
|
||||
result = taos_query(taos, "create database demo");
|
||||
if (result == NULL) {
|
||||
printf("failed to create database, reason:%s\n", "null result"/*taos_errstr(taos)*/);
|
||||
exit(1);
|
||||
}
|
||||
//result = taos_query(taos, "create database demo");
|
||||
//if (result == NULL) {
|
||||
// printf("failed to create database, reason:%s\n", "null result"/*taos_errstr(taos)*/);
|
||||
// exit(1);
|
||||
//}
|
||||
queryDB(taos, "create database demo");
|
||||
printf("success to create database\n");
|
||||
|
||||
taos_query(taos, "use demo");
|
||||
//taos_query(taos, "use demo");
|
||||
queryDB(taos, "use demo");
|
||||
|
||||
// create table
|
||||
if (taos_query(taos, "create table m1 (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10))") == 0) {
|
||||
printf("failed to create table, reason:%s\n", taos_errstr(result));
|
||||
exit(1);
|
||||
}
|
||||
//if (taos_query(taos, "create table m1 (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10))") == 0) {
|
||||
// printf("failed to create table, reason:%s\n", taos_errstr(result));
|
||||
// exit(1);
|
||||
//}
|
||||
queryDB(taos, "create table m1 (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10))");
|
||||
printf("success to create table\n");
|
||||
|
||||
// sleep for one second to make sure table is created on data node
|
||||
|
@ -80,8 +112,10 @@ int main(int argc, char *argv[]) {
|
|||
printf("insert row: %i\n", i);
|
||||
} else {
|
||||
printf("failed to insert row: %i, reason:%s\n", i, "null result"/*taos_errstr(result)*/);
|
||||
taos_free_result(result);
|
||||
exit(1);
|
||||
}
|
||||
taos_free_result(result);
|
||||
|
||||
//sleep(1);
|
||||
}
|
||||
|
@ -92,6 +126,7 @@ int main(int argc, char *argv[]) {
|
|||
result = taos_query(taos, qstr);
|
||||
if (result == NULL || taos_errno(result) != 0) {
|
||||
printf("failed to select, reason:%s\n", taos_errstr(result));
|
||||
taos_free_result(result);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
#!/bin/bash
|
||||
|
||||
today=`date +"%Y%m%d"`
|
||||
WORK_DIR=/home/ubuntu/pxiao/
|
||||
PERFORMANCE_TEST_REPORT=$TDENGINE_DIR/tests/performance-test-report-$today.log
|
||||
|
||||
# Coloured Echoes #
|
||||
function red_echo { echo -e "\033[31m$@\033[0m"; } #
|
||||
function green_echo { echo -e "\033[32m$@\033[0m"; } #
|
||||
function yellow_echo { echo -e "\033[33m$@\033[0m"; } #
|
||||
function white_echo { echo -e "\033[1;37m$@\033[0m"; } #
|
||||
# Coloured Printfs #
|
||||
function red_printf { printf "\033[31m$@\033[0m"; } #
|
||||
function green_printf { printf "\033[32m$@\033[0m"; } #
|
||||
function yellow_printf { printf "\033[33m$@\033[0m"; } #
|
||||
function white_printf { printf "\033[1;37m$@\033[0m"; } #
|
||||
# Debugging Outputs #
|
||||
function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; } #
|
||||
function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; } #
|
||||
function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } #
|
||||
function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } #
|
||||
|
||||
|
||||
function stopTaosd {
|
||||
echo "Stop taosd"
|
||||
systemctl stop taosd
|
||||
snap stop tdengine
|
||||
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
||||
while [ -n "$PID" ]
|
||||
do
|
||||
pkill -TERM -x taosd
|
||||
sleep 1
|
||||
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
|
||||
done
|
||||
}
|
||||
|
||||
function buildTDengine {
|
||||
echoInfo "Build TDengine"
|
||||
cd $WORK_DIR/TDengine
|
||||
|
||||
git remote update > /dev/null
|
||||
REMOTE_COMMIT=`git rev-parse --short remotes/origin/develop`
|
||||
LOCAL_COMMIT=`git rev-parse --short @`
|
||||
|
||||
echo " LOCAL: $LOCAL_COMMIT"
|
||||
echo "REMOTE: $REMOTE_COMMIT"
|
||||
if [ "$LOCAL_COMMIT" == "$REMOTE_COMMIT" ]; then
|
||||
echo "repo up-to-date"
|
||||
else
|
||||
echo "repo need to pull"
|
||||
git pull > /dev/null
|
||||
|
||||
LOCAL_COMMIT=`git rev-parse --short @`
|
||||
cd debug
|
||||
rm -rf *
|
||||
cmake .. > /dev/null
|
||||
make > /dev/null
|
||||
make install
|
||||
fi
|
||||
}
|
||||
|
||||
function runQueryPerfTest {
|
||||
nohup $WORK_DIR/TDengine/debug/build/bin/taosd -c /etc/taodperf/ > /dev/null 2>&1 &
|
||||
echoInfo "Run Performance Test"
|
||||
cd $WORK_DIR/TDengine/tests/pytest
|
||||
|
||||
python3 query/queryPerformance.py | tee -a $PERFORMANCE_TEST_REPORT
|
||||
}
|
||||
|
||||
|
||||
function sendReport {
|
||||
echo "send report"
|
||||
receiver="pxiao@taosdata.com"
|
||||
mimebody="MIME-Version: 1.0\nContent-Type: text/html; charset=utf-8\n"
|
||||
|
||||
cd $TDENGINE_DIR
|
||||
|
||||
sed -i 's/\x1b\[[0-9;]*m//g' $PERFORMANCE_TEST_REPORT
|
||||
BODY_CONTENT=`cat $PERFORMANCE_TEST_REPORT`
|
||||
echo -e "to: ${receiver}\nsubject: Query Performace Report ${today}, commit ID: ${LOCAL_COMMIT}\n\n${today}:\n${BODY_CONTENT}" | \
|
||||
(cat - && uuencode $PERFORMANCE_TEST_REPORT performance-test-report-$today.log) | \
|
||||
ssmtp "${receiver}" && echo "Report Sent!"
|
||||
}
|
||||
|
||||
|
||||
stopTaosd
|
||||
buildTDengine
|
||||
runQueryPerfTest
|
||||
|
||||
echoInfo "Send Report"
|
||||
sendReport
|
||||
echoInfo "End of Test"
|
|
@ -0,0 +1,71 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import random
|
||||
import string
|
||||
import subprocess
|
||||
import sys
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
def run(self):
|
||||
tdLog.debug("check database")
|
||||
tdSql.prepare()
|
||||
|
||||
# check default update value
|
||||
sql = "create database if not exists db"
|
||||
tdSql.execute(sql)
|
||||
tdSql.query('show databases')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,16,0)
|
||||
|
||||
sql = "alter database db update 1"
|
||||
|
||||
# check update value
|
||||
tdSql.execute(sql)
|
||||
tdSql.query('show databases')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,16,1)
|
||||
|
||||
|
||||
sql = "alter database db update 0"
|
||||
tdSql.execute(sql)
|
||||
tdSql.query('show databases')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,16,0)
|
||||
|
||||
sql = "alter database db update -1"
|
||||
tdSql.error(sql)
|
||||
|
||||
sql = "alter database db update 100"
|
||||
tdSql.error(sql)
|
||||
|
||||
tdSql.query('show databases')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,16,0)
|
||||
|
||||
tdSql.execute('drop database db')
|
||||
tdSql.error('create database db update 100')
|
||||
tdSql.error('create database db update -1')
|
||||
|
||||
tdSql.execute('create database db update 1')
|
||||
|
||||
tdSql.query('show databases')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,16,1)
|
||||
|
||||
tdSql.execute('drop database db')
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -38,9 +38,9 @@ import resource
|
|||
from guppy import hpy
|
||||
import gc
|
||||
|
||||
from .service_manager import ServiceManager, TdeInstance
|
||||
from .misc import Logging, Status, CrashGenError, Dice, Helper, Progress
|
||||
from .db import DbConn, MyTDSql, DbConnNative, DbManager
|
||||
from crash_gen.service_manager import ServiceManager, TdeInstance
|
||||
from crash_gen.misc import Logging, Status, CrashGenError, Dice, Helper, Progress
|
||||
from crash_gen.db import DbConn, MyTDSql, DbConnNative, DbManager
|
||||
|
||||
import taos
|
||||
import requests
|
||||
|
@ -243,7 +243,7 @@ class WorkerThread:
|
|||
|
||||
|
||||
class ThreadCoordinator:
|
||||
WORKER_THREAD_TIMEOUT = 180 # one minute
|
||||
WORKER_THREAD_TIMEOUT = 120 # Normal: 120
|
||||
|
||||
def __init__(self, pool: ThreadPool, dbManager: DbManager):
|
||||
self._curStep = -1 # first step is 0
|
||||
|
@ -388,9 +388,9 @@ 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 time-out")
|
||||
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, important thread info:")
|
||||
print("\n\nWorker Thread time-out detected, TAOS related threads are:")
|
||||
ts = ThreadStacks()
|
||||
ts.print(filterInternal=True)
|
||||
workerTimeout = True
|
||||
|
@ -435,7 +435,7 @@ class ThreadCoordinator:
|
|||
Logging.debug("\r\n\n--> Main thread ready to finish up...")
|
||||
Logging.debug("Main thread joining all threads")
|
||||
self._pool.joinAll() # Get all threads to finish
|
||||
Logging.info("\nAll worker threads finished")
|
||||
Logging.info(". . . All worker threads finished") # No CR/LF before
|
||||
self._execStats.endExec()
|
||||
|
||||
def cleanup(self): # free resources
|
||||
|
@ -1072,17 +1072,18 @@ class Database:
|
|||
t3 = datetime.datetime(2012, 1, 1) # default "keep" is 10 years
|
||||
t4 = datetime.datetime.fromtimestamp(
|
||||
t3.timestamp() + elSec2) # see explanation above
|
||||
Logging.info("Setting up TICKS to start from: {}".format(t4))
|
||||
Logging.debug("Setting up TICKS to start from: {}".format(t4))
|
||||
return t4
|
||||
|
||||
@classmethod
|
||||
def getNextTick(cls):
|
||||
with cls._clsLock: # prevent duplicate tick
|
||||
if cls._lastLaggingTick==0:
|
||||
if cls._lastLaggingTick==0 or cls._lastTick==0 : # not initialized
|
||||
# 10k at 1/20 chance, should be enough to avoid overlaps
|
||||
cls._lastLaggingTick = cls.setupLastTick() + datetime.timedelta(0, -10000)
|
||||
if cls._lastTick==0: # should be quite a bit into the future
|
||||
cls._lastTick = cls.setupLastTick()
|
||||
tick = cls.setupLastTick()
|
||||
cls._lastTick = tick
|
||||
cls._lastLaggingTick = tick + datetime.timedelta(0, -10000)
|
||||
# if : # should be quite a bit into the future
|
||||
|
||||
if Dice.throw(20) == 0: # 1 in 20 chance, return lagging tick
|
||||
cls._lastLaggingTick += datetime.timedelta(0, 1) # Go back in time 100 seconds
|
||||
|
@ -1177,6 +1178,8 @@ class Task():
|
|||
instead. But a task is always associated with a DB
|
||||
'''
|
||||
taskSn = 100
|
||||
_lock = threading.Lock()
|
||||
_tableLocks: Dict[str, threading.Lock] = {}
|
||||
|
||||
@classmethod
|
||||
def allocTaskNum(cls):
|
||||
|
@ -1198,6 +1201,8 @@ class Task():
|
|||
self._execStats = execStats
|
||||
self._db = db # A task is always associated/for a specific DB
|
||||
|
||||
|
||||
|
||||
def isSuccess(self):
|
||||
return self._err is None
|
||||
|
||||
|
@ -1237,6 +1242,7 @@ class Task():
|
|||
0x0B, # Unable to establish connection, more details in TD-1648
|
||||
0x200, # invalid SQL, TODO: re-examine with TD-934
|
||||
0x20F, # query terminated, possibly due to vnoding being dropped, see TD-1776
|
||||
0x213, # "Disconnected from service", result of "kill connection ???"
|
||||
0x217, # "db not selected", client side defined error code
|
||||
# 0x218, # "Table does not exist" client side defined error code
|
||||
0x360, # Table already exists
|
||||
|
@ -1318,7 +1324,7 @@ class Task():
|
|||
self._err = err
|
||||
self._aborted = True
|
||||
except Exception as e:
|
||||
self.logInfo("Non-TAOS exception encountered")
|
||||
Logging.info("Non-TAOS exception encountered with: {}".format(self.__class__.__name__))
|
||||
self._err = e
|
||||
self._aborted = True
|
||||
traceback.print_exc()
|
||||
|
@ -1351,6 +1357,24 @@ class Task():
|
|||
def getQueryResult(self, wt: WorkerThread): # execute an SQL on the worker thread
|
||||
return wt.getQueryResult()
|
||||
|
||||
def lockTable(self, ftName): # full table name
|
||||
# print(" <<" + ftName + '_', end="", flush=True)
|
||||
with Task._lock:
|
||||
if not ftName in Task._tableLocks:
|
||||
Task._tableLocks[ftName] = threading.Lock()
|
||||
|
||||
Task._tableLocks[ftName].acquire()
|
||||
|
||||
def unlockTable(self, ftName):
|
||||
# print('_' + ftName + ">> ", end="", flush=True)
|
||||
with Task._lock:
|
||||
if not ftName in self._tableLocks:
|
||||
raise RuntimeError("Corrupt state, no such lock")
|
||||
lock = Task._tableLocks[ftName]
|
||||
if not lock.locked():
|
||||
raise RuntimeError("Corrupte state, already unlocked")
|
||||
lock.release()
|
||||
|
||||
|
||||
class ExecutionStats:
|
||||
def __init__(self):
|
||||
|
@ -1461,7 +1485,7 @@ class StateTransitionTask(Task):
|
|||
|
||||
_baseTableNumber = None
|
||||
|
||||
_endState = None
|
||||
_endState = None # TODO: no longter used?
|
||||
|
||||
@classmethod
|
||||
def getInfo(cls): # each sub class should supply their own information
|
||||
|
@ -1486,7 +1510,7 @@ class StateTransitionTask(Task):
|
|||
|
||||
@classmethod
|
||||
def getRegTableName(cls, i):
|
||||
if ( StateTransitionTask._baseTableNumber is None):
|
||||
if ( StateTransitionTask._baseTableNumber is None): # Set it one time
|
||||
StateTransitionTask._baseTableNumber = Dice.throw(
|
||||
999) if gConfig.dynamic_db_table_names else 0
|
||||
return "reg_table_{}".format(StateTransitionTask._baseTableNumber + i)
|
||||
|
@ -1544,8 +1568,11 @@ 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'})
|
||||
{'ts':'timestamp', 'speed':'int'}, {'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))
|
||||
# No need to create the regular tables, INSERT will do that
|
||||
# automatically
|
||||
|
@ -1558,13 +1585,40 @@ class TdSuperTable:
|
|||
def getName(self):
|
||||
return self._stName
|
||||
|
||||
def drop(self, dbc, dbName, skipCheck = False):
|
||||
if self.exists(dbc, dbName) : # 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)
|
||||
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, dbName, cols: dict, tags: dict,
|
||||
dropIfExists = False
|
||||
):
|
||||
|
||||
'''Creating a super table'''
|
||||
sql = "CREATE TABLE {}.{} ({}) TAGS ({})".format(
|
||||
dbName,
|
||||
self._stName,
|
||||
",".join(['%s %s'%(k,v) for (k,v) in cols.items()]),
|
||||
dbc.execute("USE " + dbName)
|
||||
fullTableName = dbName + '.' + self._stName
|
||||
if dbc.existsSuperTable(self._stName):
|
||||
if dropIfExists:
|
||||
dbc.execute("DROP TABLE {}".format(fullTableName))
|
||||
else: # error
|
||||
raise CrashGenError("Cannot create super table, already exists: {}".format(self._stName))
|
||||
|
||||
# Now let's create
|
||||
sql = "CREATE TABLE {} ({})".format(
|
||||
fullTableName,
|
||||
",".join(['%s %s'%(k,v) for (k,v) in cols.items()]))
|
||||
if tags is None :
|
||||
sql += " TAGS (dummy int) "
|
||||
else:
|
||||
sql += " TAGS ({})".format(
|
||||
",".join(['%s %s'%(k,v) for (k,v) in tags.items()])
|
||||
)
|
||||
dbc.execute(sql)
|
||||
|
@ -1583,14 +1637,25 @@ class TdSuperTable:
|
|||
def hasRegTables(self, dbc: DbConn, dbName: str):
|
||||
return dbc.query("SELECT * FROM {}.{}".format(dbName, self._stName)) > 0
|
||||
|
||||
def ensureTable(self, dbc: DbConn, dbName: str, regTableName: str):
|
||||
def ensureTable(self, task: Task, dbc: DbConn, dbName: str, regTableName: str):
|
||||
sql = "select tbname from {}.{} where tbname in ('{}')".format(dbName, self._stName, regTableName)
|
||||
if dbc.query(sql) >= 1 : # reg table exists already
|
||||
return
|
||||
sql = "CREATE TABLE {}.{} USING {}.{} tags ({})".format(
|
||||
dbName, regTableName, dbName, self._stName, self._getTagStrForSql(dbc, dbName)
|
||||
|
||||
# acquire a lock first, so as to be able to *verify*. More details in TD-1471
|
||||
fullTableName = dbName + '.' + regTableName
|
||||
if task is not None: # optional lock
|
||||
task.lockTable(fullTableName)
|
||||
Progress.emit(Progress.CREATE_TABLE_ATTEMPT) # ATTEMPT to create a new table
|
||||
# print("(" + fullTableName[-3:] + ")", end="", flush=True)
|
||||
try:
|
||||
sql = "CREATE TABLE {} USING {}.{} tags ({})".format(
|
||||
fullTableName, dbName, self._stName, self._getTagStrForSql(dbc, dbName)
|
||||
)
|
||||
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)
|
||||
|
@ -1809,7 +1874,7 @@ class TaskRestartService(StateTransitionTask):
|
|||
|
||||
with self._classLock:
|
||||
if self._isRunning:
|
||||
print("Skipping restart task, another running already")
|
||||
Logging.info("Skipping restart task, another running already")
|
||||
return
|
||||
self._isRunning = True
|
||||
|
||||
|
@ -1847,24 +1912,21 @@ class TaskAddData(StateTransitionTask):
|
|||
def canBeginFrom(cls, state: AnyState):
|
||||
return state.canAddData()
|
||||
|
||||
def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
|
||||
# ds = self._dbManager # Quite DANGEROUS here, may result in multi-thread client access
|
||||
db = self._db
|
||||
dbc = wt.getDbConn()
|
||||
tblSeq = list(range(
|
||||
self.LARGE_NUMBER_OF_TABLES if gConfig.larger_data else self.SMALL_NUMBER_OF_TABLES))
|
||||
random.shuffle(tblSeq)
|
||||
for i in tblSeq:
|
||||
if (i in self.activeTable): # wow already active
|
||||
print("x", end="", flush=True) # concurrent insertion
|
||||
else:
|
||||
self.activeTable.add(i) # marking it active
|
||||
def _addDataInBatch(self, db, dbc, regTableName, te: TaskExecutor):
|
||||
numRecords = self.LARGE_NUMBER_OF_RECORDS if gConfig.larger_data else self.SMALL_NUMBER_OF_RECORDS
|
||||
fullTableName = db.getName() + '.' + regTableName
|
||||
|
||||
sTable = db.getFixedSuperTable()
|
||||
regTableName = self.getRegTableName(i) # "db.reg_table_{}".format(i)
|
||||
sTable.ensureTable(wt.getDbConn(), db.getName(), regTableName) # Ensure the table exists
|
||||
sql = "insert into {} values ".format(fullTableName)
|
||||
for j in range(numRecords): # number of records per table
|
||||
nextInt = db.getNextInt()
|
||||
nextTick = db.getNextTick()
|
||||
sql += "('{}', {});".format(nextTick, nextInt)
|
||||
dbc.execute(sql)
|
||||
|
||||
for j in range(self.LARGE_NUMBER_OF_RECORDS if gConfig.larger_data else self.SMALL_NUMBER_OF_RECORDS): # number of records per table
|
||||
def _addData(self, db, 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()
|
||||
if gConfig.record_ops:
|
||||
|
@ -1872,22 +1934,24 @@ class TaskAddData(StateTransitionTask):
|
|||
self.fAddLogReady.write("Ready to write {} to {}\n".format(nextInt, regTableName))
|
||||
self.fAddLogReady.flush()
|
||||
os.fsync(self.fAddLogReady)
|
||||
sql = "insert into {}.{} values ('{}', {});".format( # removed: tags ('{}', {})
|
||||
db.getName(),
|
||||
regTableName,
|
||||
|
||||
# TODO: too ugly trying to lock the table reliably, refactor...
|
||||
fullTableName = db.getName() + '.' + regTableName
|
||||
if gConfig.verify_data:
|
||||
self.lockTable(fullTableName)
|
||||
# print("_w" + str(nextInt % 100), end="", flush=True) # Trace what was written
|
||||
|
||||
try:
|
||||
sql = "insert into {} values ('{}', {});".format( # removed: tags ('{}', {})
|
||||
fullTableName,
|
||||
# ds.getFixedSuperTableName(),
|
||||
# ds.getNextBinary(), ds.getNextFloat(),
|
||||
nextTick, nextInt)
|
||||
dbc.execute(sql)
|
||||
# Successfully wrote the data into the DB, let's record it
|
||||
# somehow
|
||||
te.recordDataMark(nextInt)
|
||||
if gConfig.record_ops:
|
||||
self.fAddLogDone.write(
|
||||
"Wrote {} to {}\n".format(
|
||||
nextInt, regTableName))
|
||||
self.fAddLogDone.flush()
|
||||
os.fsync(self.fAddLogDone)
|
||||
except: # Any exception at all
|
||||
if gConfig.verify_data:
|
||||
self.unlockTable(fullTableName)
|
||||
raise
|
||||
|
||||
# Now read it back and verify, we might encounter an error if table is dropped
|
||||
if gConfig.verify_data: # only if command line asks for it
|
||||
|
@ -1905,16 +1969,52 @@ class TaskAddData(StateTransitionTask):
|
|||
"Failed to read back same data for tick: {}, wrote: {}, read: {}"
|
||||
.format(nextTick, nextInt, "Empty Result" if errno==0x991 else "Multiple Result"),
|
||||
errno)
|
||||
# Re-throw no matter what
|
||||
elif errno in [0x218, 0x362]: # table doesn't exist
|
||||
# do nothing
|
||||
dummy = 0
|
||||
else:
|
||||
# Re-throw otherwise
|
||||
raise
|
||||
finally:
|
||||
self.unlockTable(fullTableName) # Unlock the table no matter what
|
||||
|
||||
# Successfully wrote the data into the DB, let's record it somehow
|
||||
te.recordDataMark(nextInt)
|
||||
|
||||
if gConfig.record_ops:
|
||||
self.fAddLogDone.write("Wrote {} to {}\n".format(nextInt, regTableName))
|
||||
self.fAddLogDone.flush()
|
||||
os.fsync(self.fAddLogDone)
|
||||
|
||||
def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
|
||||
# ds = self._dbManager # Quite DANGEROUS here, may result in multi-thread client access
|
||||
db = self._db
|
||||
dbc = wt.getDbConn()
|
||||
numTables = self.LARGE_NUMBER_OF_TABLES if gConfig.larger_data else self.SMALL_NUMBER_OF_TABLES
|
||||
numRecords = self.LARGE_NUMBER_OF_RECORDS if gConfig.larger_data else self.SMALL_NUMBER_OF_RECORDS
|
||||
tblSeq = list(range(numTables ))
|
||||
random.shuffle(tblSeq) # now we have random sequence
|
||||
for i in tblSeq:
|
||||
if (i in self.activeTable): # wow already active
|
||||
print("x", end="", flush=True) # concurrent insertion
|
||||
else:
|
||||
self.activeTable.add(i) # marking it active
|
||||
|
||||
sTable = db.getFixedSuperTable()
|
||||
regTableName = self.getRegTableName(i) # "db.reg_table_{}".format(i)
|
||||
fullTableName = db.getName() + '.' + 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
|
||||
# self._unlockTable(fullTableName)
|
||||
|
||||
if Dice.throw(1) == 0: # 1 in 2 chance
|
||||
self._addData(db, dbc, regTableName, te)
|
||||
else:
|
||||
self._addDataInBatch(db, dbc, regTableName, te)
|
||||
|
||||
self.activeTable.discard(i) # not raising an error, unlike remove
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ThreadStacks: # stack info for all threads
|
||||
def __init__(self):
|
||||
self._allStacks = {}
|
||||
|
@ -1936,17 +2036,19 @@ class ThreadStacks: # stack info for all threads
|
|||
'__init__']: # the thread that extracted the stack
|
||||
continue # ignore
|
||||
# Now print
|
||||
print("\n<----- Thread Info for ID: {}".format(thNid))
|
||||
print("\n<----- Thread Info for LWP/ID: {} (Execution stopped at Bottom Frame) <-----".format(thNid))
|
||||
stackFrame = 0
|
||||
for frame in stack:
|
||||
# print(frame)
|
||||
print("File {filename}, line {lineno}, in {name}".format(
|
||||
filename=frame.filename, lineno=frame.lineno, name=frame.name))
|
||||
print("[{sf}] File {filename}, line {lineno}, in {name}".format(
|
||||
sf=stackFrame, filename=frame.filename, lineno=frame.lineno, name=frame.name))
|
||||
print(" {}".format(frame.line))
|
||||
print("-----> End of Thread Info\n")
|
||||
stackFrame += 1
|
||||
print("-----> End of Thread Info ----->\n")
|
||||
|
||||
class ClientManager:
|
||||
def __init__(self):
|
||||
print("Starting service manager")
|
||||
Logging.info("Starting service manager")
|
||||
# signal.signal(signal.SIGTERM, self.sigIntHandler)
|
||||
# signal.signal(signal.SIGINT, self.sigIntHandler)
|
||||
|
||||
|
@ -2048,7 +2150,7 @@ class ClientManager:
|
|||
thPool = ThreadPool(gConfig.num_threads, gConfig.max_steps)
|
||||
self.tc = ThreadCoordinator(thPool, dbManager)
|
||||
|
||||
print("Starting client instance to: {}".format(tInst))
|
||||
Logging.info("Starting client instance: {}".format(tInst))
|
||||
self.tc.run()
|
||||
# print("exec stats: {}".format(self.tc.getExecStats()))
|
||||
# print("TC failed = {}".format(self.tc.isFailed()))
|
|
@ -95,6 +95,11 @@ class DbConn:
|
|||
# print("dbs = {}, str = {}, ret2={}, type2={}".format(dbs, dbName,ret2, type(dbName)))
|
||||
return dbName in dbs # TODO: super weird type mangling seen, once here
|
||||
|
||||
def existsSuperTable(self, stName):
|
||||
self.query("show stables")
|
||||
sts = [v[0] for v in self.getQueryResult()]
|
||||
return stName in sts
|
||||
|
||||
def hasTables(self):
|
||||
return self.query("show tables") > 0
|
||||
|
||||
|
@ -240,6 +245,7 @@ class MyTDSql:
|
|||
|
||||
def _execInternal(self, sql):
|
||||
startTime = time.time()
|
||||
# Logging.debug("Executing SQL: " + sql)
|
||||
ret = self._cursor.execute(sql)
|
||||
# print("\nSQL success: {}".format(sql))
|
||||
queryTime = time.time() - startTime
|
||||
|
|
|
@ -27,7 +27,7 @@ class LoggingFilter(logging.Filter):
|
|||
|
||||
class MyLoggingAdapter(logging.LoggerAdapter):
|
||||
def process(self, msg, kwargs):
|
||||
return "[{}] {}".format(threading.get_ident() % 10000, msg), kwargs
|
||||
return "[{:04d}] {}".format(threading.get_ident() % 10000, msg), kwargs
|
||||
# return '[%s] %s' % (self.extra['connid'], msg), kwargs
|
||||
|
||||
|
||||
|
@ -51,7 +51,7 @@ class Logging:
|
|||
_logger.addHandler(ch)
|
||||
|
||||
# Logging adapter, to be used as a logger
|
||||
print("setting logger variable")
|
||||
# print("setting logger variable")
|
||||
# global logger
|
||||
cls.logger = MyLoggingAdapter(_logger, [])
|
||||
|
||||
|
@ -166,6 +166,9 @@ class Progress:
|
|||
SERVICE_RECONNECT_START = 4
|
||||
SERVICE_RECONNECT_SUCCESS = 5
|
||||
SERVICE_RECONNECT_FAILURE = 6
|
||||
SERVICE_START_NAP = 7
|
||||
CREATE_TABLE_ATTEMPT = 8
|
||||
|
||||
tokens = {
|
||||
STEP_BOUNDARY: '.',
|
||||
BEGIN_THREAD_STEP: '[',
|
||||
|
@ -174,6 +177,8 @@ class Progress:
|
|||
SERVICE_RECONNECT_START: '<r.',
|
||||
SERVICE_RECONNECT_SUCCESS: '.r>',
|
||||
SERVICE_RECONNECT_FAILURE: '.xr>',
|
||||
SERVICE_START_NAP: '_zz',
|
||||
CREATE_TABLE_ATTEMPT: '_c',
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -47,6 +47,17 @@ class TdeInstance():
|
|||
.format(selfPath, projPath))
|
||||
return buildPath
|
||||
|
||||
@classmethod
|
||||
def prepareGcovEnv(cls, env):
|
||||
# Ref: https://gcc.gnu.org/onlinedocs/gcc/Cross-profiling.html
|
||||
bPath = cls._getBuildPath() # build PATH
|
||||
numSegments = len(bPath.split('/')) - 1 # "/x/TDengine/build" should yield 3
|
||||
numSegments = numSegments - 1 # DEBUG only
|
||||
env['GCOV_PREFIX'] = bPath + '/svc_gcov'
|
||||
env['GCOV_PREFIX_STRIP'] = str(numSegments) # Strip every element, plus, ENV needs strings
|
||||
Logging.info("Preparing GCOV environement to strip {} elements and use path: {}".format(
|
||||
numSegments, env['GCOV_PREFIX'] ))
|
||||
|
||||
def __init__(self, subdir='test', tInstNum=0, port=6030, fepPort=6030):
|
||||
self._buildDir = self._getBuildPath()
|
||||
self._subdir = '/' + subdir # TODO: tolerate "/"
|
||||
|
@ -217,6 +228,11 @@ class TdeSubProcess:
|
|||
# raise CrashGenError("Empty instance not allowed in TdeSubProcess")
|
||||
# self._tInst = tInst # Default create at ServiceManagerThread
|
||||
|
||||
def __repr__(self):
|
||||
if self.subProcess is None:
|
||||
return '[TdeSubProc: Empty]'
|
||||
return '[TdeSubProc: pid = {}]'.format(self.getPid())
|
||||
|
||||
def getStdOut(self):
|
||||
return self.subProcess.stdout
|
||||
|
||||
|
@ -236,16 +252,29 @@ class TdeSubProcess:
|
|||
if self.subProcess: # already there
|
||||
raise RuntimeError("Corrupt process state")
|
||||
|
||||
# Prepare environment variables for coverage information
|
||||
# Ref: https://stackoverflow.com/questions/2231227/python-subprocess-popen-with-a-modified-environment
|
||||
myEnv = os.environ.copy()
|
||||
TdeInstance.prepareGcovEnv(myEnv)
|
||||
|
||||
# print(myEnv)
|
||||
# print(myEnv.items())
|
||||
# print("Starting TDengine via Shell: {}".format(cmdLineStr))
|
||||
|
||||
useShell = True
|
||||
self.subProcess = subprocess.Popen(
|
||||
cmdLine,
|
||||
shell=False,
|
||||
' '.join(cmdLine) if useShell else cmdLine,
|
||||
shell=useShell,
|
||||
# svcCmdSingle, shell=True, # capture core dump?
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
# bufsize=1, # not supported in binary mode
|
||||
close_fds=ON_POSIX
|
||||
close_fds=ON_POSIX,
|
||||
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?
|
||||
|
||||
def stop(self):
|
||||
"""
|
||||
Stop a sub process, and try to return a meaningful return code.
|
||||
|
@ -267,7 +296,7 @@ class TdeSubProcess:
|
|||
SIGUSR2 12
|
||||
"""
|
||||
if not self.subProcess:
|
||||
print("Sub process already stopped")
|
||||
Logging.error("Sub process already stopped")
|
||||
return # -1
|
||||
|
||||
retCode = self.subProcess.poll() # ret -N means killed with signal N, otherwise it's from exit(N)
|
||||
|
@ -278,20 +307,25 @@ class TdeSubProcess:
|
|||
return retCode
|
||||
|
||||
# process still alive, let's interrupt it
|
||||
print("Terminate running process, send SIG_INT and wait...")
|
||||
Logging.info("Terminate running process, send SIG_{} and wait...".format(self.STOP_SIGNAL))
|
||||
# sub process should end, then IPC queue should end, causing IO thread to end
|
||||
# sig = signal.SIGINT
|
||||
sig = signal.SIGKILL
|
||||
self.subProcess.send_signal(sig) # SIGNINT or SIGKILL
|
||||
topSubProc = psutil.Process(self.subProcess.pid)
|
||||
for child in topSubProc.children(recursive=True): # or parent.children() for recursive=False
|
||||
child.send_signal(self.STOP_SIGNAL)
|
||||
time.sleep(0.2) # 200 ms
|
||||
# topSubProc.send_signal(sig) # now kill the main sub process (likely the Shell)
|
||||
|
||||
self.subProcess.send_signal(self.STOP_SIGNAL) # main sub process (likely the Shell)
|
||||
self.subProcess.wait(20)
|
||||
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):
|
||||
Logging.error("TSP.stop(): Failed to stop sub proc properly w/ SIG {}, retCode={}".format(sig, retCode))
|
||||
Logging.error("TSP.stop(): Failed to stop sub proc properly w/ SIG {}, retCode={}".format(
|
||||
self.STOP_SIGNAL, retCode))
|
||||
else:
|
||||
Logging.info("TSP.stop(): sub proc successfully terminated with SIG {}".format(sig))
|
||||
Logging.info("TSP.stop(): sub proc successfully terminated with SIG {}".format(self.STOP_SIGNAL))
|
||||
return - retCode
|
||||
|
||||
class ServiceManager:
|
||||
|
@ -439,7 +473,7 @@ class ServiceManager:
|
|||
|
||||
time.sleep(self.PAUSE_BETWEEN_IPC_CHECK) # pause, before next round
|
||||
# raise CrashGenError("dummy")
|
||||
print("Service Manager Thread (with subprocess) ended, main thread exiting...")
|
||||
Logging.info("Service Manager Thread (with subprocess) ended, main thread exiting...")
|
||||
|
||||
def _getFirstInstance(self):
|
||||
return self._tInsts[0]
|
||||
|
@ -452,7 +486,7 @@ class ServiceManager:
|
|||
# Find if there's already a taosd service, and then kill it
|
||||
for proc in psutil.process_iter():
|
||||
if proc.name() == 'taosd':
|
||||
print("Killing an existing TAOSD process in 2 seconds... press CTRL-C to interrupt")
|
||||
Logging.info("Killing an existing TAOSD process in 2 seconds... press CTRL-C to interrupt")
|
||||
time.sleep(2.0)
|
||||
proc.kill()
|
||||
# print("Process: {}".format(proc.name()))
|
||||
|
@ -559,7 +593,8 @@ class ServiceManagerThread:
|
|||
for i in range(0, 100):
|
||||
time.sleep(1.0)
|
||||
# self.procIpcBatch() # don't pump message during start up
|
||||
print("_zz_", end="", flush=True)
|
||||
Progress.emit(Progress.SERVICE_START_NAP)
|
||||
# print("_zz_", end="", flush=True)
|
||||
if self._status.isRunning():
|
||||
Logging.info("[] TDengine service READY to process requests")
|
||||
Logging.info("[] TAOS service started: {}".format(self))
|
||||
|
@ -595,12 +630,12 @@ class ServiceManagerThread:
|
|||
|
||||
def stop(self):
|
||||
# can be called from both main thread or signal handler
|
||||
print("Terminating TDengine service running as the sub process...")
|
||||
Logging.info("Terminating TDengine service running as the sub process...")
|
||||
if self.getStatus().isStopped():
|
||||
print("Service already stopped")
|
||||
Logging.info("Service already stopped")
|
||||
return
|
||||
if self.getStatus().isStopping():
|
||||
print("Service is already being stopped")
|
||||
Logging.info("Service is already being stopped")
|
||||
return
|
||||
# Linux will send Control-C generated SIGINT to the TDengine process
|
||||
# already, ref:
|
||||
|
@ -616,10 +651,10 @@ class ServiceManagerThread:
|
|||
if retCode == signal.SIGSEGV : # SGV
|
||||
Logging.error("[[--ERROR--]]: TDengine service SEGV fault (check core file!)")
|
||||
except subprocess.TimeoutExpired as err:
|
||||
print("Time out waiting for TDengine service process to exit")
|
||||
Logging.info("Time out waiting for TDengine service process to exit")
|
||||
else:
|
||||
if self._tdeSubProcess.isRunning(): # still running, should now never happen
|
||||
print("FAILED to stop sub process, it is still running... pid = {}".format(
|
||||
Logging.error("FAILED to stop sub process, it is still running... pid = {}".format(
|
||||
self._tdeSubProcess.getPid()))
|
||||
else:
|
||||
self._tdeSubProcess = None # not running any more
|
||||
|
@ -683,9 +718,9 @@ class ServiceManagerThread:
|
|||
return # we are done with THIS BATCH
|
||||
else: # got line, printing out
|
||||
if forceOutput:
|
||||
Logging.info(line)
|
||||
Logging.info('[TAOSD] ' + line)
|
||||
else:
|
||||
Logging.debug(line)
|
||||
Logging.debug('[TAOSD] ' + line)
|
||||
print(">", end="", flush=True)
|
||||
|
||||
_ProgressBars = ["--", "//", "||", "\\\\"]
|
||||
|
@ -728,11 +763,11 @@ class ServiceManagerThread:
|
|||
|
||||
# queue.put(line)
|
||||
# meaning sub process must have died
|
||||
Logging.info("\nEnd of stream detected for TDengine STDOUT: {}".format(self))
|
||||
Logging.info("EOF for TDengine STDOUT: {}".format(self))
|
||||
out.close()
|
||||
|
||||
def svcErrorReader(self, err: IO, queue):
|
||||
for line in iter(err.readline, b''):
|
||||
print("\nTDengine Service (taosd) ERROR (from stderr): {}".format(line))
|
||||
Logging.info("\nEnd of stream detected for TDengine STDERR: {}".format(self))
|
||||
Logging.info("TDengine STDERR: {}".format(line))
|
||||
Logging.info("EOF for TDengine STDERR: {}".format(self))
|
||||
err.close()
|
|
@ -11,7 +11,7 @@
|
|||
###################################################################
|
||||
|
||||
import sys
|
||||
from crash_gen.crash_gen import MainExec
|
||||
from crash_gen.crash_gen_main import MainExec
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ 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/parser.py
|
||||
python3 ./test.py -f stream/history.py
|
||||
|
||||
#alter table
|
||||
|
@ -207,3 +207,20 @@ python3 test.py -f tools/taosdemo.py
|
|||
python3 test.py -f subscribe/singlemeter.py
|
||||
#python3 test.py -f subscribe/stability.py
|
||||
python3 test.py -f subscribe/supertable.py
|
||||
|
||||
|
||||
# update
|
||||
python3 ./test.py -f update/allow_update.py
|
||||
python3 ./test.py -f update/allow_update-0.py
|
||||
python3 ./test.py -f update/append_commit_data.py
|
||||
python3 ./test.py -f update/append_commit_last-0.py
|
||||
python3 ./test.py -f update/append_commit_last.py
|
||||
python3 ./test.py -f update/merge_commit_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
|
|
@ -132,6 +132,17 @@ class TDTestCase:
|
|||
tdSql.query("select apercentile(col6, 100) from test")
|
||||
print("apercentile result: %s" % tdSql.getData(0, 0))
|
||||
|
||||
tdSql.execute("create table meters (ts timestamp, voltage int) tags(loc nchar(20))")
|
||||
tdSql.execute("create table t0 using meters tags('beijing')")
|
||||
tdSql.execute("create table t1 using meters tags('shanghai')")
|
||||
for i in range(self.rowNum):
|
||||
tdSql.execute("insert into t0 values(%d, %d)" % (self.ts + i, i + 1))
|
||||
tdSql.execute("insert into t1 values(%d, %d)" % (self.ts + i, i + 1))
|
||||
|
||||
tdSql.error("select percentile(voltage, 20) from meters")
|
||||
tdSql.query("select apercentile(voltage, 20) from meters")
|
||||
print("apercentile result: %s" % tdSql.getData(0, 0))
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
|
|
@ -5,7 +5,9 @@ GREEN='\033[1;32m'
|
|||
GREEN_DARK='\033[0;32m'
|
||||
GREEN_UNDERLINE='\033[4;32m'
|
||||
NC='\033[0m'
|
||||
|
||||
nohup /root/TDinternal/debug/build/bin/taosd -c /root/TDinternal/community/sim/dnode1/cfg >/dev/null &
|
||||
./crash_gen.sh --valgrind -p -t 10 -s 100 -b 4
|
||||
pidof taosd|xargs kill
|
||||
grep 'start to execute\|ERROR SUMMARY' valgrind.err|grep -v 'grep'|uniq|tee crash_gen_mem_err.log
|
||||
|
||||
for memError in `grep 'ERROR SUMMARY' crash_gen_mem_err.log | awk '{print $4}'`
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import requests, json
|
||||
import threading
|
||||
import string
|
||||
import random
|
||||
import time
|
||||
|
||||
class RestfulInsert:
|
||||
def init(self):
|
||||
self.header = {'Authorization': 'Basic cm9vdDp0YW9zZGF0YQ=='}
|
||||
self.url = "http://ningsi60:6041/rest/sql"
|
||||
self.ts = 1104508800000
|
||||
self.numOfThreads = 10
|
||||
self.numOfTables = 3000
|
||||
self.dbName = 'netmonitortaos'
|
||||
self.stbName = 'devinfomt'
|
||||
self.prefix = 'dev'
|
||||
|
||||
def get_random_string(self, length):
|
||||
letters = string.ascii_lowercase
|
||||
result_str = ''.join(random.choice(letters) for i in range(length))
|
||||
return result_str
|
||||
|
||||
def createTables(self, threadID):
|
||||
print("create table: thread %d started" % threadID)
|
||||
tablesPerThread = int (self.numOfTables / self.numOfThreads)
|
||||
for i in range(tablesPerThread):
|
||||
data = "create table '%s'.dev_%d using '%s'.'%s' tags('%s', '%s')" % (self.dbName, i + threadID * tablesPerThread, self.dbName, self.stbName, self.get_random_string(25), self.get_random_string(25))
|
||||
response = requests.post(self.url, data, headers = self.header)
|
||||
if response.status_code != 200:
|
||||
print(response.content)
|
||||
|
||||
def insertData(self, threadID):
|
||||
print("insert data: thread %d started" % threadID)
|
||||
tablesPerThread = int (self.numOfTables / self.numOfThreads)
|
||||
base_ts = self.ts
|
||||
while True:
|
||||
i = 0
|
||||
for i in range(tablesPerThread):
|
||||
data = "insert into %s.dev_%d values(%d, '%s', '%s', %d, %d, %d)" % (self.dbName, i + threadID * tablesPerThread, base_ts, self.get_random_string(25), self.get_random_string(30), random.randint(1, 10000), random.randint(1, 10000), random.randint(1, 10000))
|
||||
response = requests.post(self.url, data, headers = self.header)
|
||||
if response.status_code != 200:
|
||||
print(response.content)
|
||||
|
||||
time.sleep(30)
|
||||
base_ts = base_ts + 1
|
||||
|
||||
def run(self):
|
||||
data = "create database if not exists %s keep 7300" % self.dbName
|
||||
requests.post(self.url, data, headers = self.header)
|
||||
|
||||
data = "create table '%s'.'%s' (timeid timestamp, devdesc binary(50), devname binary(50), cpu bigint, temp bigint, ram bigint) tags(devid binary(50), modelid binary(50))" % (self.dbName, self.stbName)
|
||||
requests.post(self.url, data, headers = self.header)
|
||||
|
||||
threads = []
|
||||
for i in range(self.numOfThreads):
|
||||
thread = threading.Thread(target=self.createTables, args=(i,))
|
||||
thread.start()
|
||||
threads.append(thread)
|
||||
|
||||
for i in range(self.numOfThreads):
|
||||
threads[i].join()
|
||||
|
||||
threads = []
|
||||
for i in range(self.numOfThreads):
|
||||
thread = threading.Thread(target=self.insertData, args=(i,))
|
||||
thread.start()
|
||||
threads.append(thread)
|
||||
|
||||
for i in range(self.numOfThreads):
|
||||
threads[i].join()
|
||||
|
||||
ri = RestfulInsert()
|
||||
ri.init()
|
||||
ri.run()
|
|
@ -0,0 +1,59 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
|
||||
tdSql.execute("create table join_mt0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12))")
|
||||
tdSql.execute("create table join_mt1 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12))")
|
||||
stable=0
|
||||
insertRows = 1000
|
||||
tbnum = 3
|
||||
t0 = 1604298064000
|
||||
tdLog.info("insert %d rows" % (insertRows))
|
||||
for i in range(tbnum):
|
||||
tdSql.execute("create table join_tb%d using join_mt%d tags(%d,'abc')" %(i,stable,i))
|
||||
for j in range(insertRows):
|
||||
ret = tdSql.execute(
|
||||
"insert into join_tb%d values (%d , %d,%d,%d,%d,%d,%d,%d, '%s','%s')" %
|
||||
(i,t0+i,i%100,i%100,i%100,i%100,i%100,i%100,i%100,'binary'+str(i%100),'nchar'+str(i%100)))
|
||||
stable=stable+1
|
||||
for i in range(tbnum):
|
||||
tdSql.execute("create table join_1_tb%d using join_mt%d tags(%d,'abc')" %(i,stable,i))
|
||||
for j in range(insertRows):
|
||||
ret = tdSql.execute(
|
||||
"insert into join_tb%d values (%d , %d,%d,%d,%d,%d,%d,%d, '%s','%s')" %
|
||||
(i,t0+i,i%100,i%100,i%100,i%100,i%100,i%100,i%100,'binary'+str(i%100),'nchar'+str(i%100)))
|
||||
print("==========step2")
|
||||
print("join query ")
|
||||
tdLog.info("select count(join_mt0.c1), first(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2, join_mt1.t1 order by join_mt0.ts desc, join_mt1.ts asc limit 10;")
|
||||
tdSql.error("select count(join_mt0.c1), first(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2, join_mt1.t1 order by join_mt0.ts desc, join_mt1.ts asc limit 10;")
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,60 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
|
||||
tdSql.execute("create table join_mt0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12))")
|
||||
tdSql.execute("create table join_mt1 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12))")
|
||||
stable=0
|
||||
insertRows = 1000
|
||||
tbnum = 3
|
||||
t0 = 1604298064000
|
||||
tdLog.info("insert %d rows" % (insertRows))
|
||||
for i in range(tbnum):
|
||||
tdSql.execute("create table join_tb%d using join_mt%d tags(%d,'abc')" %(i,stable,i))
|
||||
for j in range(insertRows):
|
||||
ret = tdSql.execute(
|
||||
"insert into join_tb%d values (%d , %d,%d,%d,%d,%d,%d,%d, '%s','%s')" %
|
||||
(i,t0+i,i%100,i%100,i%100,i%100,i%100,i%100,i%100,'binary'+str(i%100),'nchar'+str(i%100)))
|
||||
stable=stable+1
|
||||
for i in range(tbnum):
|
||||
tdSql.execute("create table join_1_tb%d using join_mt%d tags(%d,'abc')" %(i,stable,i))
|
||||
for j in range(insertRows):
|
||||
ret = tdSql.execute(
|
||||
"insert into join_tb%d values (%d , %d,%d,%d,%d,%d,%d,%d, '%s','%s')" %
|
||||
(i,t0+i,i%100,i%100,i%100,i%100,i%100,i%100,i%100,'binary'+str(i%100),'nchar'+str(i%100)))
|
||||
print("==========step2")
|
||||
print("join query ")
|
||||
tdLog.info("select count(join_mt0.c1), first(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2, join_mt1.t1 order by join_mt0.ts desc, join_mt1.ts asc limit 10;")
|
||||
tdSql.error("select count(join_mt0.c1), first(join_mt0.c1), first(join_mt1.c9) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2 order by join_mt0.t1 desc")
|
||||
tdSql.error("select count(join_mt0.c1), first(join_mt0.c1), first(join_mt1.c9) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2 order by join_mt0.t1 desc limit 3;")
|
||||
tdSql.error("select count(join_mt0.c1), first(join_mt0.c1), first(join_mt1.c9) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2 order by join_mt0.t1 desc slimit 3;")
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,58 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
|
||||
tdSql.execute("create table join_mt0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12))")
|
||||
tdSql.execute("create table join_mt1 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12))")
|
||||
stable=0
|
||||
insertRows = 1000
|
||||
tbnum = 3
|
||||
t0 = 1604298064000
|
||||
tdLog.info("insert %d rows" % (insertRows))
|
||||
for i in range(tbnum):
|
||||
tdSql.execute("create table join_tb%d using join_mt%d tags(%d,'abc')" %(i,stable,i))
|
||||
for j in range(insertRows):
|
||||
ret = tdSql.execute(
|
||||
"insert into join_tb%d values (%d , %d,%d,%d,%d,%d,%d,%d, '%s','%s')" %
|
||||
(i,t0+i,i%100,i%100,i%100,i%100,i%100,i%100,i%100,'binary'+str(i%100),'nchar'+str(i%100)))
|
||||
stable=stable+1
|
||||
for i in range(tbnum):
|
||||
tdSql.execute("create table join_1_tb%d using join_mt%d tags(%d,'abc')" %(i,stable,i))
|
||||
for j in range(insertRows):
|
||||
ret = tdSql.execute(
|
||||
"insert into join_tb%d values (%d , %d,%d,%d,%d,%d,%d,%d, '%s','%s')" %
|
||||
(i,t0+i,i%100,i%100,i%100,i%100,i%100,i%100,i%100,'binary'+str(i%100),'nchar'+str(i%100)))
|
||||
print("==========step2")
|
||||
print("join query ")
|
||||
tdLog.info("select count(join_mt0.c1), first(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1, join_mt0.t2, join_mt1.t1 order by join_mt0.ts desc, join_mt1.ts asc limit 10;")
|
||||
tdSql.error("select count(join_mt0.c1), first(join_mt0.c1)-first(join_mt1.c1), first(join_mt1.c9) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts;")
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,82 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import taos
|
||||
from util.log import tdLog
|
||||
from util.cases import tdCases
|
||||
from util.sql import tdSql
|
||||
from util.dnodes import tdDnodes
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
"""
|
||||
kill query
|
||||
"""
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
|
||||
def query(self):
|
||||
conn = taos.connect(host='127.0.0.1', user='root', password='taosdata', config='/etc/config')
|
||||
cursor = conn.cursor()
|
||||
while True:
|
||||
cursor.execute('show queries;')
|
||||
print('show queries!')
|
||||
temp = cursor.fetchall()
|
||||
if temp:
|
||||
print(temp[0][0])
|
||||
cursor.execute('kill query %s ;' % temp[0][0])
|
||||
print('kill query success')
|
||||
break
|
||||
time.sleep(0.5)
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
|
||||
print("==============step1")
|
||||
os.system('yes | sudo taosdemo -n 100')
|
||||
print('insert into test.meters 10000000 rows')
|
||||
|
||||
|
||||
t1 = threading.Thread(target=self.query)
|
||||
t1.setDaemon(True)
|
||||
t1.start()
|
||||
|
||||
print("==============step2")
|
||||
tdSql.execute('use test;')
|
||||
try:
|
||||
print('============begin select * from 10000000 rows')
|
||||
tdSql.query('select * from test.meters;')
|
||||
# print(tdSql.queryResult)
|
||||
except Exception as e:
|
||||
if not "ProgrammingError('Query terminated'" in str(e):
|
||||
raise Exception('fail')
|
||||
|
||||
print('success')
|
||||
print('kill query success')
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import taos
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor())
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
|
||||
tdSql.execute("create table cars(ts timestamp, c nchar(2)) tags(t1 nchar(2))")
|
||||
tdSql.execute("insert into car0 using cars tags('aa') values(now, 'bb');")
|
||||
tdSql.query("select count(*) from cars where t1 like '%50 90 30 04 00 00%'")
|
||||
tdSql.checkRows(0)
|
||||
|
||||
tdSql.execute("create table test_cars(ts timestamp, c nchar(2)) tags(t1 nchar(20))")
|
||||
tdSql.execute("insert into car1 using test_cars tags('150 90 30 04 00 002') values(now, 'bb');")
|
||||
tdSql.query("select * from test_cars where t1 like '%50 90 30 04 00 00%'")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,219 @@
|
|||
import time
|
||||
import taos
|
||||
import csv
|
||||
import numpy as np
|
||||
import random
|
||||
import os
|
||||
import requests
|
||||
import json
|
||||
import sys
|
||||
|
||||
"""
|
||||
需要第三方库: taos,requests,numpy
|
||||
当前机器已经启动taosd服务
|
||||
使用方法见底部示例
|
||||
"""
|
||||
|
||||
|
||||
|
||||
class Ding:
|
||||
"""
|
||||
发送消息到钉钉,
|
||||
urls: 钉钉群的token组成的list,可以发多个钉钉群,需要提前加白名单或其他放行策略
|
||||
at_mobiles: 需要@的人的手机号组成的list
|
||||
msg: 要发送的str
|
||||
"""
|
||||
def __init__(self, url_list, at_mobiles):
|
||||
self.urls = url_list
|
||||
self.at_mobiles = at_mobiles
|
||||
|
||||
def send_message(self, msg):
|
||||
data1 = {
|
||||
"msgtype": "text",
|
||||
"text": {
|
||||
"content": msg
|
||||
},
|
||||
"at": {
|
||||
"atMobiles": self.at_mobiles,
|
||||
"isAtAll": False
|
||||
}
|
||||
}
|
||||
|
||||
header = {'Content-Type': 'application/json; charset=utf-8'}
|
||||
|
||||
for url in self.urls:
|
||||
requests.post(url=url, data=json.dumps(data1), headers=header)
|
||||
|
||||
|
||||
|
||||
|
||||
class TDConn:
|
||||
def __init__(self, config:dict):
|
||||
self.host = config['host']
|
||||
self.user = config['user']
|
||||
self.password = config['password']
|
||||
self.config = config['config']
|
||||
self.conn = None
|
||||
self.cursor = None
|
||||
|
||||
def connect(self):
|
||||
conn = taos.connect(host=self.host, user=self.user, password=self.password, config=self.config)
|
||||
cursor = conn.cursor()
|
||||
self.conn = conn
|
||||
self.cursor = cursor
|
||||
print('connect ...')
|
||||
return self.cursor
|
||||
|
||||
def close(self):
|
||||
self.cursor.close()
|
||||
self.conn.close()
|
||||
print('close ... ')
|
||||
|
||||
|
||||
class Tool:
|
||||
"""
|
||||
可能有用
|
||||
"""
|
||||
@staticmethod
|
||||
def str_gen(num):
|
||||
return ''.join(random.sample('abcdefghijklmnopqrstuvwxyz', num))
|
||||
|
||||
@staticmethod
|
||||
def float_gen(n, m):
|
||||
return random.uniform(n, m)
|
||||
|
||||
@staticmethod
|
||||
def int_gen(n, m):
|
||||
return random.randint(n, m)
|
||||
|
||||
class Demo:
|
||||
def __init__(self, engine):
|
||||
self.engine = engine['engine'](engine['config'])
|
||||
self.cursor = self.engine.connect()
|
||||
|
||||
|
||||
def date_gen(self, db, number_per_table, type_of_cols, num_of_cols_per_record, num_of_tables):
|
||||
"""
|
||||
:目前都是 taosdemo 的参数
|
||||
:return:
|
||||
"""
|
||||
sql = 'yes | sudo taosdemo -d {db} -n {number_per_table} -b {type_of_cols} -l {num_of_cols_per_record} ' \
|
||||
'-t {num_of_tables}'.format(db=db, number_per_table=number_per_table, type_of_cols=type_of_cols,
|
||||
num_of_cols_per_record=num_of_cols_per_record, num_of_tables=num_of_tables)
|
||||
os.system(sql)
|
||||
print('insert data completed')
|
||||
|
||||
|
||||
# def main(self, db, circle, csv_name, case_func, result_csv, nums, ding_flag):
|
||||
def main(self, every_num_per_table, result_csv, all_result_csv, values):
|
||||
db = values['db_name']
|
||||
number_per_table = every_num_per_table
|
||||
type_of_cols = values['col_type']
|
||||
num_of_cols_per_record = values['col_num']
|
||||
num_of_tables = values['table_num']
|
||||
self.date_gen(db=db, number_per_table=number_per_table, type_of_cols=type_of_cols,
|
||||
num_of_cols_per_record=num_of_cols_per_record, num_of_tables=num_of_tables)
|
||||
|
||||
circle = values['circle']
|
||||
# print(every_num_per_table, result_csv, values)
|
||||
csv_name = result_csv
|
||||
case_func = values['sql_func']
|
||||
nums = num_of_tables * number_per_table
|
||||
ding_flag = values['ding_flag']
|
||||
|
||||
_data = []
|
||||
f = open(csv_name,'w',encoding='utf-8')
|
||||
f1 = open(all_result_csv,'a',encoding='utf-8')
|
||||
csv_writer = csv.writer(f)
|
||||
csv_writer1 = csv.writer(f1)
|
||||
csv_writer.writerow(["number", "elapse", 'sql'])
|
||||
self.cursor.execute('use {db};'.format(db=db))
|
||||
|
||||
|
||||
for i in range(circle):
|
||||
self.cursor.execute('reset query cache;')
|
||||
sql = case_func()
|
||||
start = time.time()
|
||||
self.cursor.execute(sql)
|
||||
self.cursor.fetchall()
|
||||
end = time.time()
|
||||
_data.append(end-start)
|
||||
elapse = '%.4f' %(end -start)
|
||||
print(sql, i, elapse, '\n')
|
||||
csv_writer.writerow([i+1, elapse, sql])
|
||||
|
||||
# time.sleep(1)
|
||||
_list = [nums, np.mean(_data)]
|
||||
_str = '总数据: %s 条 , table数: %s , 每个table数据数: %s , 数据类型: %s \n' % \
|
||||
(nums, num_of_tables, number_per_table, type_of_cols)
|
||||
# print('avg : ', np.mean(_data), '\n')
|
||||
_str += '平均值 : %.4f 秒\n' % np.mean(_data)
|
||||
for each in (50, 80, 90, 95):
|
||||
_list.append(np.percentile(_data,each))
|
||||
_str += ' %d 分位数 : %.4f 秒\n' % (each , np.percentile(_data,each))
|
||||
|
||||
print(_str)
|
||||
if ding_flag:
|
||||
ding = Ding(values['ding_config']['urls'], values['ding_config']['at_mobiles'])
|
||||
ding.send_message(_str)
|
||||
csv_writer1.writerow(_list)
|
||||
f.close()
|
||||
f1.close()
|
||||
self.engine.close()
|
||||
|
||||
|
||||
def run(engine, test_cases: dict, result_dir):
|
||||
for each_case, values in test_cases.items():
|
||||
for every_num_per_table in values['number_per_table']:
|
||||
result_csv = result_dir + '{case}_table{table_num}_{number_per_table}.csv'.\
|
||||
format(case=each_case, table_num=values['table_num'], number_per_table=every_num_per_table)
|
||||
all_result_csv = result_dir + '{case_all}_result.csv'.format(case_all=each_case)
|
||||
d = Demo(engine)
|
||||
# print(each_case, result_csv)
|
||||
d.main(every_num_per_table, result_csv, all_result_csv, values)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
"""
|
||||
测试用例在test_cases中添加。
|
||||
result_dir: 报告生成目录,会生成每次测试结果,和具体某一用例的统计结果.需注意目录权限需要执行用户可写。
|
||||
case1、case2 : 具体用例名称
|
||||
engine: 数据库引擎,目前只有taosd。使用时需开启taosd服务。
|
||||
table_num: 造数据时的table数目
|
||||
circle: 循环测试次数,求平均值
|
||||
number_per_table:需要传list,多个数值代表会按照list内的数值逐个测试
|
||||
col_num:table col的数目
|
||||
col_type: 表中数据类型
|
||||
db_name: 造数据的db名,默认用test
|
||||
sql_func: 当前测试的sql方法,需要自己定义
|
||||
ding_flag: 如果需要钉钉发送数据,flag设置真值,
|
||||
ding_config: 如ding_flag 设置为真值,此项才有意义。ding_flag为假时此项可以为空。urls传入一list,内容为要发送的群的token,
|
||||
需提前设置白名单,at_mobiles传入一list,内容为在群内需要@的人的手机号
|
||||
"""
|
||||
engine_dict = {
|
||||
'taosd': {'engine': TDConn, 'config':
|
||||
{'host': '127.0.0.1', 'user': 'root', 'password': 'taosdata', 'config':'/etc/taos'}}
|
||||
}
|
||||
|
||||
def case1():
|
||||
return 'select * from meters where f1 = {n};'.format(n=random.randint(1,30))
|
||||
|
||||
def case2():
|
||||
return 'select * from meters where f1 = %.4f;' %random.uniform(1,30)
|
||||
|
||||
|
||||
result_dir = '/usr/local/demo/benchmarktestdata/'
|
||||
test_cases = {
|
||||
'case1': {'engine':'taosd', 'table_num': 10, 'circle': 100, 'number_per_table':[10, 100], 'col_num': 5,
|
||||
'col_type': 'INT', 'db_name': 'test', 'sql_func': case1, 'ding_flag': True,
|
||||
'ding_config':
|
||||
{'urls': [r'https://oapi.dingtalk.com/robot/send?access_token=xxxxxxx0cd93'],
|
||||
'at_mobiles':[17000000000,],}},
|
||||
'case2': {'engine':'taosd', 'table_num': 10, 'circle': 50, 'number_per_table':[10, 100], 'col_num': 5,
|
||||
'col_type': 'FLOAT', 'db_name': 'test', 'sql_func': case2, 'ding_flag': False,
|
||||
'ding_config': None
|
||||
}
|
||||
}
|
||||
|
||||
run(engine_dict['taosd'], test_cases, result_dir)
|
|
@ -0,0 +1,170 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import taos
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
self.numOfRecords = 10
|
||||
self.ts = 1604295582000
|
||||
|
||||
def restartTaosd(self):
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.execute("use udb")
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
startTs = self.ts
|
||||
|
||||
print("==============step1")
|
||||
tdSql.execute("create database udb update 0")
|
||||
tdSql.execute("use udb")
|
||||
tdSql.execute("create table t (ts timestamp, a int)")
|
||||
tdSql.execute("insert into t values (%d, 1)" % (startTs))
|
||||
tdSql.execute("insert into t values (%d, 1)" % (startTs - 3))
|
||||
tdSql.execute("insert into t values (%d, 1)" % (startTs + 3))
|
||||
|
||||
tdSql.query("select * from t")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.query("select a from t")
|
||||
tdSql.checkData(0, 0, 1)
|
||||
tdSql.checkData(1, 0, 1)
|
||||
tdSql.checkData(2, 0, 1)
|
||||
|
||||
print("==============step2")
|
||||
tdSql.execute("insert into t values (%d, 2)" % (startTs))
|
||||
tdSql.execute("insert into t values (%d, 2)" % (startTs - 3))
|
||||
tdSql.execute("insert into t values (%d, 2)" % (startTs + 3))
|
||||
|
||||
tdSql.query("select * from t")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.query("select a from t")
|
||||
tdSql.checkData(0, 0, 1)
|
||||
tdSql.checkData(1, 0, 1)
|
||||
tdSql.checkData(2, 0, 1)
|
||||
|
||||
print("==============step3")
|
||||
tdSql.execute("insert into t values (%d, 3)" % (startTs - 4))
|
||||
tdSql.execute("insert into t values (%d, 3)" % (startTs - 2))
|
||||
tdSql.execute("insert into t values (%d, 3)" % (startTs + 2))
|
||||
tdSql.execute("insert into t values (%d, 3)" % (startTs + 4))
|
||||
|
||||
tdSql.query("select * from t")
|
||||
tdSql.checkRows(7)
|
||||
|
||||
tdSql.query("select a from t")
|
||||
tdSql.checkData(0, 0, 3)
|
||||
tdSql.checkData(1, 0, 1)
|
||||
tdSql.checkData(2, 0, 3)
|
||||
tdSql.checkData(3, 0, 1)
|
||||
tdSql.checkData(4, 0, 3)
|
||||
tdSql.checkData(5, 0, 1)
|
||||
tdSql.checkData(6, 0, 3)
|
||||
|
||||
print("==============step4")
|
||||
tdSql.execute("insert into t values (%d, 4)" % (startTs - 4))
|
||||
tdSql.execute("insert into t values (%d, 4)" % (startTs - 2))
|
||||
tdSql.execute("insert into t values (%d, 4)" % (startTs + 2))
|
||||
tdSql.execute("insert into t values (%d, 4)" % (startTs + 4))
|
||||
|
||||
tdSql.query("select * from t")
|
||||
tdSql.checkRows(7)
|
||||
|
||||
tdSql.query("select a from t")
|
||||
tdSql.checkData(0, 0, 3)
|
||||
tdSql.checkData(1, 0, 1)
|
||||
tdSql.checkData(2, 0, 3)
|
||||
tdSql.checkData(3, 0, 1)
|
||||
tdSql.checkData(4, 0, 3)
|
||||
tdSql.checkData(5, 0, 1)
|
||||
tdSql.checkData(6, 0, 3)
|
||||
|
||||
print("==============step5")
|
||||
tdSql.execute("insert into t values (%d, 5)" % (startTs - 1))
|
||||
tdSql.execute("insert into t values (%d, 5)" % (startTs + 1))
|
||||
|
||||
tdSql.query("select * from t")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
tdSql.query("select a from t")
|
||||
tdSql.checkData(0, 0, 3)
|
||||
tdSql.checkData(1, 0, 1)
|
||||
tdSql.checkData(2, 0, 3)
|
||||
tdSql.checkData(3, 0, 5)
|
||||
tdSql.checkData(4, 0, 1)
|
||||
tdSql.checkData(5, 0, 5)
|
||||
tdSql.checkData(6, 0, 3)
|
||||
tdSql.checkData(7, 0, 1)
|
||||
tdSql.checkData(8, 0, 3)
|
||||
|
||||
print("==============step6")
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs - 4))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs - 3))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs - 2))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs - 1))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs + 1))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs + 2))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs + 3))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs + 4))
|
||||
|
||||
tdSql.query("select * from t")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
tdSql.query("select a from t")
|
||||
tdSql.checkData(0, 0, 3)
|
||||
tdSql.checkData(1, 0, 1)
|
||||
tdSql.checkData(2, 0, 3)
|
||||
tdSql.checkData(3, 0, 5)
|
||||
tdSql.checkData(4, 0, 1)
|
||||
tdSql.checkData(5, 0, 5)
|
||||
tdSql.checkData(6, 0, 3)
|
||||
tdSql.checkData(7, 0, 1)
|
||||
tdSql.checkData(8, 0, 3)
|
||||
|
||||
# restart taosd to commit, and check
|
||||
self.restartTaosd();
|
||||
|
||||
tdSql.query("select * from t")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
tdSql.query("select a from t")
|
||||
tdSql.checkData(0, 0, 3)
|
||||
tdSql.checkData(1, 0, 1)
|
||||
tdSql.checkData(2, 0, 3)
|
||||
tdSql.checkData(3, 0, 5)
|
||||
tdSql.checkData(4, 0, 1)
|
||||
tdSql.checkData(5, 0, 5)
|
||||
tdSql.checkData(6, 0, 3)
|
||||
tdSql.checkData(7, 0, 1)
|
||||
tdSql.checkData(8, 0, 3)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,266 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import taos
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
self.numOfRecords = 10
|
||||
self.ts = 1604295582000
|
||||
|
||||
def restartTaosd(self):
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.execute("use udb")
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
startTs = self.ts
|
||||
|
||||
tdSql.execute("create database udb update 1")
|
||||
tdSql.execute("use udb")
|
||||
tdSql.execute("create table t (ts timestamp, a int)")
|
||||
|
||||
print("==============step1")
|
||||
tdSql.execute("insert into t values (%d, 1)" % (startTs))
|
||||
tdSql.execute("insert into t values (%d, 1)" % (startTs - 3))
|
||||
tdSql.execute("insert into t values (%d, 1)" % (startTs + 3))
|
||||
|
||||
tdSql.query("select * from t")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.query("select a from t")
|
||||
tdSql.checkData(0, 0, 1)
|
||||
tdSql.checkData(1, 0, 1)
|
||||
tdSql.checkData(2, 0, 1)
|
||||
|
||||
print("==============step2")
|
||||
tdSql.execute("insert into t values (%d, 2)" % (startTs))
|
||||
tdSql.execute("insert into t values (%d, 2)" % (startTs - 3))
|
||||
tdSql.execute("insert into t values (%d, 2)" % (startTs + 3))
|
||||
|
||||
tdSql.query("select * from t")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.query("select a from t")
|
||||
tdSql.checkData(0, 0, 2)
|
||||
tdSql.checkData(1, 0, 2)
|
||||
tdSql.checkData(2, 0, 2)
|
||||
|
||||
print("==============step3")
|
||||
tdSql.execute("insert into t values (%d, 3)" % (startTs - 4))
|
||||
tdSql.execute("insert into t values (%d, 3)" % (startTs - 2))
|
||||
tdSql.execute("insert into t values (%d, 3)" % (startTs + 2))
|
||||
tdSql.execute("insert into t values (%d, 3)" % (startTs + 4))
|
||||
|
||||
tdSql.query("select * from t")
|
||||
tdSql.checkRows(7)
|
||||
|
||||
tdSql.query("select a from t")
|
||||
tdSql.checkData(0, 0, 3)
|
||||
tdSql.checkData(1, 0, 2)
|
||||
tdSql.checkData(2, 0, 3)
|
||||
tdSql.checkData(3, 0, 2)
|
||||
tdSql.checkData(4, 0, 3)
|
||||
tdSql.checkData(5, 0, 2)
|
||||
tdSql.checkData(6, 0, 3)
|
||||
|
||||
print("==============step4")
|
||||
tdSql.execute("insert into t values (%d, 4)" % (startTs - 4))
|
||||
tdSql.execute("insert into t values (%d, 4)" % (startTs - 2))
|
||||
tdSql.execute("insert into t values (%d, 4)" % (startTs + 2))
|
||||
tdSql.execute("insert into t values (%d, 4)" % (startTs + 4))
|
||||
|
||||
tdSql.query("select * from t")
|
||||
tdSql.checkRows(7)
|
||||
|
||||
tdSql.query("select a from t")
|
||||
tdSql.checkData(0, 0, 4)
|
||||
tdSql.checkData(1, 0, 2)
|
||||
tdSql.checkData(2, 0, 4)
|
||||
tdSql.checkData(3, 0, 2)
|
||||
tdSql.checkData(4, 0, 4)
|
||||
tdSql.checkData(5, 0, 2)
|
||||
tdSql.checkData(6, 0, 4)
|
||||
|
||||
print("==============step5")
|
||||
tdSql.execute("insert into t values (%d, 5)" % (startTs - 1))
|
||||
tdSql.execute("insert into t values (%d, 5)" % (startTs + 1))
|
||||
|
||||
tdSql.query("select * from t")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
tdSql.query("select a from t")
|
||||
tdSql.checkData(0, 0, 4)
|
||||
tdSql.checkData(1, 0, 2)
|
||||
tdSql.checkData(2, 0, 4)
|
||||
tdSql.checkData(3, 0, 5)
|
||||
tdSql.checkData(4, 0, 2)
|
||||
tdSql.checkData(5, 0, 5)
|
||||
tdSql.checkData(6, 0, 4)
|
||||
tdSql.checkData(7, 0, 2)
|
||||
tdSql.checkData(8, 0, 4)
|
||||
|
||||
print("==============step6")
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs - 4))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs - 3))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs - 2))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs - 1))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs + 1))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs + 2))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs + 3))
|
||||
tdSql.execute("insert into t values (%d, 6)" % (startTs + 4))
|
||||
|
||||
tdSql.query("select * from t")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
tdSql.query("select a from t")
|
||||
tdSql.checkData(0, 0, 6)
|
||||
tdSql.checkData(1, 0, 6)
|
||||
tdSql.checkData(2, 0, 6)
|
||||
tdSql.checkData(3, 0, 6)
|
||||
tdSql.checkData(4, 0, 6)
|
||||
tdSql.checkData(5, 0, 6)
|
||||
tdSql.checkData(6, 0, 6)
|
||||
tdSql.checkData(7, 0, 6)
|
||||
tdSql.checkData(8, 0, 6)
|
||||
|
||||
# restart taosd to commit, and check
|
||||
self.restartTaosd();
|
||||
|
||||
tdSql.query("select * from t")
|
||||
tdSql.checkRows(9)
|
||||
|
||||
tdSql.query("select a from t")
|
||||
tdSql.checkData(0, 0, 6)
|
||||
tdSql.checkData(1, 0, 6)
|
||||
tdSql.checkData(2, 0, 6)
|
||||
tdSql.checkData(3, 0, 6)
|
||||
tdSql.checkData(4, 0, 6)
|
||||
tdSql.checkData(5, 0, 6)
|
||||
tdSql.checkData(6, 0, 6)
|
||||
tdSql.checkData(7, 0, 6)
|
||||
tdSql.checkData(8, 0, 6)
|
||||
|
||||
tdSql.execute("create table subt (ts timestamp, a int, b float, c binary(16), d bool)")
|
||||
|
||||
print("==============step7")
|
||||
tdSql.execute("insert into subt (ts, a, c) values (%d, 1, 'c+0')" % (startTs))
|
||||
tdSql.execute("insert into subt (ts, a, c) values (%d, 1, 'c-3')" % (startTs - 3))
|
||||
tdSql.execute("insert into subt (ts, a, c) values (%d, 1, 'c+3')" % (startTs + 3))
|
||||
|
||||
tdSql.query("select * from subt")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.query("select a,b,c,d from subt")
|
||||
tdSql.checkData(0, 0, 1)
|
||||
tdSql.checkData(1, 0, 1)
|
||||
tdSql.checkData(2, 0, 1)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(1, 1, None)
|
||||
tdSql.checkData(2, 1, None)
|
||||
tdSql.checkData(0, 2, 'c-3')
|
||||
tdSql.checkData(1, 2, 'c+0')
|
||||
tdSql.checkData(2, 2, 'c+3')
|
||||
tdSql.checkData(0, 3, None)
|
||||
tdSql.checkData(1, 3, None)
|
||||
tdSql.checkData(2, 3, None)
|
||||
|
||||
print("==============step8")
|
||||
tdSql.execute("insert into subt (ts, b, d) values (%d, 2.0, true)" % (startTs))
|
||||
tdSql.execute("insert into subt (ts, b, d) values (%d, 2.0, true)" % (startTs - 3))
|
||||
tdSql.execute("insert into subt (ts, b, d) values (%d, 2.0, false)" % (startTs + 3))
|
||||
|
||||
tdSql.query("select * from subt")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.query("select a,b,c,d from subt")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(1, 0, None)
|
||||
tdSql.checkData(2, 0, None)
|
||||
tdSql.checkData(0, 1, 2.0)
|
||||
tdSql.checkData(1, 1, 2.0)
|
||||
tdSql.checkData(2, 1, 2.0)
|
||||
tdSql.checkData(0, 2, None)
|
||||
tdSql.checkData(1, 2, None)
|
||||
tdSql.checkData(2, 2, None)
|
||||
tdSql.checkData(0, 3, 1)
|
||||
tdSql.checkData(1, 3, 1)
|
||||
tdSql.checkData(2, 3, 0)
|
||||
|
||||
# restart taosd to commit, and check
|
||||
self.restartTaosd();
|
||||
|
||||
tdSql.query("select * from subt")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.query("select a,b,c,d from subt")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(1, 0, None)
|
||||
tdSql.checkData(2, 0, None)
|
||||
tdSql.checkData(0, 1, 2.0)
|
||||
tdSql.checkData(1, 1, 2.0)
|
||||
tdSql.checkData(2, 1, 2.0)
|
||||
tdSql.checkData(0, 2, None)
|
||||
tdSql.checkData(1, 2, None)
|
||||
tdSql.checkData(2, 2, None)
|
||||
tdSql.checkData(0, 3, 1)
|
||||
tdSql.checkData(1, 3, 1)
|
||||
tdSql.checkData(2, 3, 0)
|
||||
|
||||
|
||||
|
||||
tdSql.execute("create table ct (ts timestamp, a int, b float, c binary(128))")
|
||||
|
||||
print("==============step9")
|
||||
insertRows = 20000
|
||||
for i in range(0, insertRows):
|
||||
tdSql.execute("insert into ct values (%d , %d, %d, 'aabbccddeeffgghhiijjkkllmmoonn112233445566778899xxyyzz')" % (startTs + i, i, i))
|
||||
|
||||
tdSql.query("select * from ct")
|
||||
tdSql.checkRows(insertRows)
|
||||
|
||||
for i in range(0, insertRows):
|
||||
tdSql.execute("insert into ct values (%d , %d, %d, 'aabbccddeeffgghhiijjkkllmmoonn112233445566778899xxyyzz')" % (startTs + i, i+insertRows, i+insertRows))
|
||||
|
||||
tdSql.query("select * from ct")
|
||||
tdSql.checkRows(insertRows)
|
||||
|
||||
tdSql.query("select a,b from ct limit 3")
|
||||
tdSql.checkData(0, 0, insertRows+0)
|
||||
tdSql.checkData(1, 0, insertRows+1)
|
||||
tdSql.checkData(2, 0, insertRows+2)
|
||||
|
||||
tdSql.checkData(0, 1, insertRows+0)
|
||||
tdSql.checkData(1, 1, insertRows+1)
|
||||
tdSql.checkData(2, 1, insertRows+2)
|
||||
|
||||
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,84 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def run(self):
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
s = 'reset query cache'
|
||||
tdSql.execute(s)
|
||||
s = 'drop database if exists db'
|
||||
tdSql.execute(s)
|
||||
s = 'create database db'
|
||||
tdSql.execute(s)
|
||||
s = 'use db'
|
||||
tdSql.execute(s)
|
||||
ret = tdSql.execute('create table t1 (ts timestamp, a int)')
|
||||
|
||||
insertRows = 200
|
||||
t0 = 1604298064000
|
||||
tdLog.info("insert %d rows" % (insertRows))
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t1 values (%d , 1)' %
|
||||
(t0+i))
|
||||
print("==========step2")
|
||||
print("restart to commit ")
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from db.t1")
|
||||
tdSql.checkRows(insertRows)
|
||||
for k in range(0,100):
|
||||
tdLog.info("insert %d rows" % (insertRows))
|
||||
for i in range (0,insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into db.t1 values(%d,1)' %
|
||||
(t0+k*200+i)
|
||||
)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from db.t1")
|
||||
tdSql.checkRows(insertRows+200*k)
|
||||
print("==========step2")
|
||||
print("insert into another table ")
|
||||
s = 'use db'
|
||||
tdSql.execute(s)
|
||||
ret = tdSql.execute('create table t2 (ts timestamp, a int)')
|
||||
insertRows = 20000
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t2 values (%d, 1)' %
|
||||
(t0+i))
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(insertRows)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,84 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def run(self):
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
s = 'reset query cache'
|
||||
tdSql.execute(s)
|
||||
s = 'drop database if exists db'
|
||||
tdSql.execute(s)
|
||||
s = 'create database db update 1'
|
||||
tdSql.execute(s)
|
||||
s = 'use db'
|
||||
tdSql.execute(s)
|
||||
ret = tdSql.execute('create table t1 (ts timestamp, a int)')
|
||||
|
||||
insertRows = 200
|
||||
t0 = 1604298064000
|
||||
tdLog.info("insert %d rows" % (insertRows))
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t1 values (%d , 1)' %
|
||||
(t0+i))
|
||||
print("==========step2")
|
||||
print("restart to commit ")
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from db.t1")
|
||||
tdSql.checkRows(insertRows)
|
||||
for k in range(0,100):
|
||||
tdLog.info("insert %d rows" % (insertRows))
|
||||
for i in range (0,insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into db.t1 values(%d,1)' %
|
||||
(t0+k*200+i)
|
||||
)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from db.t1")
|
||||
tdSql.checkRows(insertRows+200*k)
|
||||
print("==========step2")
|
||||
print("insert into another table ")
|
||||
s = 'use db'
|
||||
tdSql.execute(s)
|
||||
ret = tdSql.execute('create table t2 (ts timestamp, a int)')
|
||||
insertRows = 20000
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t2 values (%d, 1)' %
|
||||
(t0+i))
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(insertRows)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,90 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import taos
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor())
|
||||
|
||||
self.ts = 1604298064000
|
||||
|
||||
def restartTaosd(self):
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.startWithoutSleep(1)
|
||||
tdSql.execute("use db")
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
|
||||
print("==============step1")
|
||||
tdSql.execute("create table t1 (ts timestamp, a int)")
|
||||
|
||||
for i in range(10):
|
||||
tdSql.execute("insert into t1 values(%d, 1)" % (self.ts + i))
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(i + 1)
|
||||
tdSql.query("select sum(a) from t1")
|
||||
tdSql.checkData(0, 0, i + 1)
|
||||
|
||||
print("==============step2")
|
||||
tdSql.execute("create table t2 (ts timestamp, a int)")
|
||||
tdSql.execute("insert into t2 values(%d, 1)" % self.ts)
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 1)
|
||||
|
||||
for i in range(1, 151):
|
||||
tdSql.execute("insert into t2 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(151)
|
||||
tdSql.query("select sum(a) from t2")
|
||||
tdSql.checkData(0, 0, 151)
|
||||
|
||||
|
||||
print("==============step3")
|
||||
tdSql.execute("create table t3 (ts timestamp, a int)")
|
||||
tdSql.execute("insert into t3 values(%d, 1)" % self.ts)
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 1)
|
||||
|
||||
for i in range(8):
|
||||
for j in range(1, 11):
|
||||
tdSql.execute("insert into t3 values(%d, 1)" % (self.ts + i * 10 + j))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(81)
|
||||
tdSql.query("select sum(a) from t3")
|
||||
tdSql.checkData(0, 0, 81)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,85 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import taos
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor())
|
||||
|
||||
self.ts = 1604298064000
|
||||
|
||||
def restartTaosd(self):
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.startWithoutSleep(1)
|
||||
tdSql.execute("use udb")
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
|
||||
print("==============step1")
|
||||
tdSql.execute("create database udb update 1")
|
||||
tdSql.execute("use udb")
|
||||
tdSql.execute("create table t1 (ts timestamp, a int)")
|
||||
|
||||
for i in range(10):
|
||||
tdSql.execute("insert into t1 values(%d, 1)" % (self.ts + i))
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(i + 1)
|
||||
|
||||
|
||||
print("==============step2")
|
||||
tdSql.execute("create table t2 (ts timestamp, a int)")
|
||||
tdSql.execute("insert into t2 values(%d, 1)" % self.ts)
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
for i in range(1, 151):
|
||||
tdSql.execute("insert into t2 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(151)
|
||||
|
||||
|
||||
print("==============step3")
|
||||
tdSql.execute("create table t3 (ts timestamp, a int)")
|
||||
tdSql.execute("insert into t3 values(%d, 1)" % self.ts)
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
for i in range(8):
|
||||
for j in range(1, 11):
|
||||
tdSql.execute("insert into t3 values(%d, 1)" % (self.ts + i * 10 + j))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(81)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,351 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def run(self):
|
||||
print("==========step1")
|
||||
print("UPDATE THE WHOLE DATA BLOCK REPEATEDLY")
|
||||
s = 'reset query cache'
|
||||
tdSql.execute(s)
|
||||
s = 'drop database if exists db'
|
||||
tdSql.execute(s)
|
||||
s = 'create database db days 30'
|
||||
tdSql.execute(s)
|
||||
s = 'use db'
|
||||
tdSql.execute(s)
|
||||
ret = tdSql.execute('create table t1 (ts timestamp, a int)')
|
||||
|
||||
insertRows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % (insertRows))
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t1 values (%d , 1)' %
|
||||
(t0 + i))
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(insertRows)
|
||||
|
||||
for k in range(0,10):
|
||||
for i in range (0,insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t1 values(%d,1)' %
|
||||
(t0+i)
|
||||
)
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(insertRows)
|
||||
print("==========step2")
|
||||
print("PREPEND DATA ")
|
||||
ret = tdSql.execute('create table t2 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t2 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(-100,0):
|
||||
ret = tdSql.execute(
|
||||
'insert into t2 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(insertRows+100)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(insertRows+100)
|
||||
print("==========step3")
|
||||
print("PREPEND MASSIVE DATA ")
|
||||
ret = tdSql.execute('create table t3 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t3 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(-6000,0):
|
||||
ret = tdSql.execute(
|
||||
'insert into t3 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(insertRows+6000)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(insertRows+6000)
|
||||
print("==========step4")
|
||||
print("APPEND DATA")
|
||||
ret = tdSql.execute('create table t4 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t4 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t4")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t4")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(0,100):
|
||||
ret = tdSql.execute(
|
||||
'insert into t4 values (%d , 1)' %
|
||||
(t0+200+i))
|
||||
tdSql.query("select * from t4")
|
||||
tdSql.checkRows(insertRows+100)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t4")
|
||||
tdSql.checkRows(insertRows+100)
|
||||
print("==========step5")
|
||||
print("APPEND DATA")
|
||||
ret = tdSql.execute('create table t5 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t5 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(0,6000):
|
||||
ret = tdSql.execute(
|
||||
'insert into t5 values (%d , 1)' %
|
||||
(t0+200+i))
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(insertRows+6000)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(insertRows+6000)
|
||||
print("==========step6")
|
||||
print("UPDATE BLOCK IN TWO STEP")
|
||||
ret = tdSql.execute('create table t6 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t6 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(0,100):
|
||||
ret = tdSql.execute(
|
||||
'insert into t6 values (%d , 2)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdSql.query("select sum(a) from t6")
|
||||
tdSql.checkData(0,0,'200')
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdSql.query("select sum(a) from t6")
|
||||
tdSql.checkData(0,0,'200')
|
||||
for i in range(0,200):
|
||||
ret = tdSql.execute(
|
||||
'insert into t6 values (%d , 2)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdSql.query("select sum(a) from t6")
|
||||
tdSql.checkData(0,0,'200')
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdSql.query("select sum(a) from t6")
|
||||
tdSql.checkData(0,0,'200')
|
||||
print("==========step7")
|
||||
print("UPDATE LAST HALF AND INSERT LITTLE DATA")
|
||||
ret = tdSql.execute('create table t7 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t7 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t7")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t7")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(100,300):
|
||||
ret = tdSql.execute(
|
||||
'insert into t7 values (%d , 2)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t7")
|
||||
tdSql.checkRows(300)
|
||||
tdSql.query("select sum(a) from t7")
|
||||
tdSql.checkData(0,0,'400')
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t7")
|
||||
tdSql.checkRows(300)
|
||||
tdSql.query("select sum(a) from t7")
|
||||
tdSql.checkData(0,0,'400')
|
||||
print("==========step8")
|
||||
print("UPDATE LAST HALF AND INSERT MASSIVE DATA")
|
||||
ret = tdSql.execute('create table t8 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t8 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t8")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t8")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(6000):
|
||||
ret = tdSql.execute(
|
||||
'insert into t8 values (%d , 2)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t8")
|
||||
tdSql.checkRows(6000)
|
||||
tdSql.query("select sum(a) from t8")
|
||||
tdSql.checkData(0,0,'11800')
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t8")
|
||||
tdSql.checkRows(6000)
|
||||
tdSql.query("select sum(a) from t8")
|
||||
tdSql.checkData(0,0,'11800')
|
||||
print("==========step9")
|
||||
print("UPDATE FIRST HALF AND PREPEND LITTLE DATA")
|
||||
ret = tdSql.execute('create table t9 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t9 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t9")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t9")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(-100,100):
|
||||
ret = tdSql.execute(
|
||||
'insert into t9 values (%d , 2)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t9")
|
||||
tdSql.checkRows(300)
|
||||
tdSql.query("select sum(a) from t9")
|
||||
tdSql.checkData(0,0,'400')
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t9")
|
||||
tdSql.checkRows(300)
|
||||
tdSql.query("select sum(a) from t9")
|
||||
tdSql.checkData(0,0,'400')
|
||||
print("==========step10")
|
||||
print("UPDATE FIRST HALF AND PREPEND MASSIVE DATA")
|
||||
ret = tdSql.execute('create table t10 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t10 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t10")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t10")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(-6000,100):
|
||||
ret = tdSql.execute(
|
||||
'insert into t10 values (%d , 2)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t10")
|
||||
tdSql.checkRows(6200)
|
||||
tdSql.query("select sum(a) from t10")
|
||||
tdSql.checkData(0,0,'12200')
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t10")
|
||||
tdSql.checkRows(6200)
|
||||
tdSql.query("select sum(a) from t10")
|
||||
tdSql.checkData(0,0,'12200')
|
||||
print("==========step11")
|
||||
print("UPDATE FIRST HALF AND APPEND MASSIVE DATA")
|
||||
ret = tdSql.execute('create table t11 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t11 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t11")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t11")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(100):
|
||||
ret = tdSql.execute(
|
||||
'insert into t11 values (%d , 2)' %
|
||||
(t0+i))
|
||||
for i in range(200,6000):
|
||||
ret = tdSql.execute(
|
||||
'insert into t11 values (%d , 2)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t11")
|
||||
tdSql.checkRows(6000)
|
||||
tdSql.query("select sum(a) from t11")
|
||||
tdSql.checkData(0,0,'11800')
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t11")
|
||||
tdSql.checkRows(6000)
|
||||
tdSql.query("select sum(a) from t11")
|
||||
tdSql.checkData(0,0,'11800')
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,351 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def run(self):
|
||||
print("==========step1")
|
||||
print("UPDATE THE WHOLE DATA BLOCK REPEATEDLY")
|
||||
s = 'reset query cache'
|
||||
tdSql.execute(s)
|
||||
s = 'drop database if exists db'
|
||||
tdSql.execute(s)
|
||||
s = 'create database db update 1 days 30'
|
||||
tdSql.execute(s)
|
||||
s = 'use db'
|
||||
tdSql.execute(s)
|
||||
ret = tdSql.execute('create table t1 (ts timestamp, a int)')
|
||||
|
||||
insertRows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % (insertRows))
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t1 values (%d , 1)' %
|
||||
(t0 + i))
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(insertRows)
|
||||
|
||||
for k in range(0,10):
|
||||
for i in range (0,insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t1 values(%d,1)' %
|
||||
(t0+i)
|
||||
)
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(insertRows)
|
||||
print("==========step2")
|
||||
print("PREPEND DATA ")
|
||||
ret = tdSql.execute('create table t2 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t2 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(-100,0):
|
||||
ret = tdSql.execute(
|
||||
'insert into t2 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(insertRows+100)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(insertRows+100)
|
||||
print("==========step3")
|
||||
print("PREPEND MASSIVE DATA ")
|
||||
ret = tdSql.execute('create table t3 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t3 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(-6000,0):
|
||||
ret = tdSql.execute(
|
||||
'insert into t3 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(insertRows+6000)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(insertRows+6000)
|
||||
print("==========step4")
|
||||
print("APPEND DATA")
|
||||
ret = tdSql.execute('create table t4 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t4 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t4")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t4")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(0,100):
|
||||
ret = tdSql.execute(
|
||||
'insert into t4 values (%d , 1)' %
|
||||
(t0+200+i))
|
||||
tdSql.query("select * from t4")
|
||||
tdSql.checkRows(insertRows+100)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t4")
|
||||
tdSql.checkRows(insertRows+100)
|
||||
print("==========step5")
|
||||
print("APPEND DATA")
|
||||
ret = tdSql.execute('create table t5 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t5 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(0,6000):
|
||||
ret = tdSql.execute(
|
||||
'insert into t5 values (%d , 1)' %
|
||||
(t0+200+i))
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(insertRows+6000)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(insertRows+6000)
|
||||
print("==========step6")
|
||||
print("UPDATE BLOCK IN TWO STEP")
|
||||
ret = tdSql.execute('create table t6 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t6 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(0,100):
|
||||
ret = tdSql.execute(
|
||||
'insert into t6 values (%d , 2)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdSql.query("select sum(a) from t6")
|
||||
tdSql.checkData(0,0,'300')
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdSql.query("select sum(a) from t6")
|
||||
tdSql.checkData(0,0,'300')
|
||||
for i in range(0,200):
|
||||
ret = tdSql.execute(
|
||||
'insert into t6 values (%d , 2)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdSql.query("select sum(a) from t6")
|
||||
tdSql.checkData(0,0,'400')
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdSql.query("select sum(a) from t6")
|
||||
tdSql.checkData(0,0,'400')
|
||||
print("==========step7")
|
||||
print("UPDATE LAST HALF AND INSERT LITTLE DATA")
|
||||
ret = tdSql.execute('create table t7 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t7 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t7")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t7")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(100,300):
|
||||
ret = tdSql.execute(
|
||||
'insert into t7 values (%d , 2)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t7")
|
||||
tdSql.checkRows(300)
|
||||
tdSql.query("select sum(a) from t7")
|
||||
tdSql.checkData(0,0,'500')
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t7")
|
||||
tdSql.checkRows(300)
|
||||
tdSql.query("select sum(a) from t7")
|
||||
tdSql.checkData(0,0,'500')
|
||||
print("==========step8")
|
||||
print("UPDATE LAST HALF AND INSERT MASSIVE DATA")
|
||||
ret = tdSql.execute('create table t8 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t8 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t8")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t8")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(6000):
|
||||
ret = tdSql.execute(
|
||||
'insert into t8 values (%d , 2)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t8")
|
||||
tdSql.checkRows(6000)
|
||||
tdSql.query("select sum(a) from t8")
|
||||
tdSql.checkData(0,0,'12000')
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t8")
|
||||
tdSql.checkRows(6000)
|
||||
tdSql.query("select sum(a) from t8")
|
||||
tdSql.checkData(0,0,'12000')
|
||||
print("==========step9")
|
||||
print("UPDATE FIRST HALF AND PREPEND LITTLE DATA")
|
||||
ret = tdSql.execute('create table t9 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t9 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t9")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t9")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(-100,100):
|
||||
ret = tdSql.execute(
|
||||
'insert into t9 values (%d , 2)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t9")
|
||||
tdSql.checkRows(300)
|
||||
tdSql.query("select sum(a) from t9")
|
||||
tdSql.checkData(0,0,'500')
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t9")
|
||||
tdSql.checkRows(300)
|
||||
tdSql.query("select sum(a) from t9")
|
||||
tdSql.checkData(0,0,'500')
|
||||
print("==========step10")
|
||||
print("UPDATE FIRST HALF AND PREPEND MASSIVE DATA")
|
||||
ret = tdSql.execute('create table t10 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t10 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t10")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t10")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(-6000,100):
|
||||
ret = tdSql.execute(
|
||||
'insert into t10 values (%d , 2)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t10")
|
||||
tdSql.checkRows(6200)
|
||||
tdSql.query("select sum(a) from t10")
|
||||
tdSql.checkData(0,0,'12300')
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t10")
|
||||
tdSql.checkRows(6200)
|
||||
tdSql.query("select sum(a) from t10")
|
||||
tdSql.checkData(0,0,'12300')
|
||||
print("==========step11")
|
||||
print("UPDATE FIRST HALF AND APPEND MASSIVE DATA")
|
||||
ret = tdSql.execute('create table t11 (ts timestamp, a int)')
|
||||
insertRows = 200
|
||||
for i in range(0, insertRows):
|
||||
ret = tdSql.execute(
|
||||
'insert into t11 values (%d , 1)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t11")
|
||||
tdSql.checkRows(insertRows)
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t11")
|
||||
tdSql.checkRows(insertRows)
|
||||
for i in range(100):
|
||||
ret = tdSql.execute(
|
||||
'insert into t11 values (%d , 2)' %
|
||||
(t0+i))
|
||||
for i in range(200,6000):
|
||||
ret = tdSql.execute(
|
||||
'insert into t11 values (%d , 2)' %
|
||||
(t0+i))
|
||||
tdSql.query("select * from t11")
|
||||
tdSql.checkRows(6000)
|
||||
tdSql.query("select sum(a) from t11")
|
||||
tdSql.checkData(0,0,'11900')
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.query("select * from t11")
|
||||
tdSql.checkRows(6000)
|
||||
tdSql.query("select sum(a) from t11")
|
||||
tdSql.checkData(0,0,'11900')
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,352 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
import time
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
|
||||
def restart_taosd(self,db):
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.startWithoutSleep(1)
|
||||
tdSql.execute("use %s;" % db)
|
||||
|
||||
def date_to_timestamp_microseconds(self, date):
|
||||
datetime_obj = datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f")
|
||||
obj_stamp = int(time.mktime(datetime_obj.timetuple()) * 1000.0 + datetime_obj.microsecond / 1000.0)
|
||||
return obj_stamp
|
||||
|
||||
def timestamp_microseconds_to_date(self, timestamp):
|
||||
d = datetime.datetime.fromtimestamp(timestamp/1000)
|
||||
str1 = d.strftime("%Y-%m-%d %H:%M:%S.%f")
|
||||
return str1
|
||||
|
||||
|
||||
|
||||
def run(self):
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
sql = 'reset query cache'
|
||||
tdSql.execute(sql)
|
||||
sql = 'drop database if exists db'
|
||||
tdSql.execute(sql)
|
||||
sql = 'create database db update 1 days 30;'
|
||||
tdSql.execute(sql)
|
||||
sql = 'use db;'
|
||||
tdSql.execute(sql)
|
||||
tdSql.execute('create table t1 (ts timestamp, a int)')
|
||||
|
||||
|
||||
print("==================================1 start")
|
||||
insert_rows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % insert_rows)
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t1 values (%d , 1)' %(t0+i))
|
||||
print("==========step2")
|
||||
print("restart to commit ")
|
||||
self.restart_taosd('db')
|
||||
|
||||
print('check query result after restart')
|
||||
tdSql.query('select * from db.t1;')
|
||||
for i in range(insert_rows):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
print("==========step3")
|
||||
print('insert data')
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t1 values (%d , 1)' %(t0+i+5000))
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t1;')
|
||||
for i in range(insert_rows, insert_rows*2):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
self.restart_taosd('db')
|
||||
print('check query result after restart')
|
||||
tdSql.query('select * from db.t1;')
|
||||
for i in range(insert_rows, insert_rows*2):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
print("==========step4")
|
||||
print('insert data')
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t1 values (%d , 2)' %(t0+i))
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t1 values (%d , 1)' %(t0+i+5000))
|
||||
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t1;')
|
||||
print(tdSql.queryResult)
|
||||
for i in range(insert_rows):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(insert_rows, insert_rows*2):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
print('check query result after restart')
|
||||
self.restart_taosd('db')
|
||||
tdSql.query('select * from db.t1;')
|
||||
# print(tdSql.queryResult)
|
||||
for i in range(insert_rows):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(insert_rows, insert_rows*2):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
print("==================================2 start")
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
tdSql.execute('create table t2 (ts timestamp, a int)')
|
||||
insert_rows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % insert_rows)
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t2 values (%d , 1)' %(t0+i))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t2 values (%d , 1)' %(t0+i+5000))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for k in range(10):
|
||||
for i in range(10):
|
||||
tdSql.execute('insert into t2 values (%d , 1)' %(t0 + 200 + k * 10 + i))
|
||||
print('insert into t2 values (%d , 1)' %(t0 + 200 + k * 10 + i))
|
||||
|
||||
|
||||
print("==========step2")
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t2;')
|
||||
for i in range(insert_rows*2+100):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
# print(tdSql.queryResult)
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
print('check query result after restart')
|
||||
tdSql.query('select * from db.t2;')
|
||||
for i in range(insert_rows*2+100):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
|
||||
print("==================================3 start")
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
tdSql.execute('create table t3 (ts timestamp, a int)')
|
||||
insert_rows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % insert_rows)
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t3 values (%d , 1)' %(t0+i))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t3 values (%d , 1)' %(t0+i+5000))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(5200):
|
||||
tdSql.execute('insert into t3 values (%d , 2)' %(t0+i))
|
||||
|
||||
print("==========step2")
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t3;')
|
||||
for i in range(5200):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
# print(tdSql.queryResult)
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
print('check query result after restart')
|
||||
tdSql.query('select * from db.t3;')
|
||||
for i in range(5200):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
|
||||
print("==================================4 start")
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
tdSql.execute('create table t4 (ts timestamp, a int)')
|
||||
insert_rows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % insert_rows)
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t4 values (%d , 1)' %(t0+i))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t4 values (%d , 1)' %(t0+i+5000))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(100):
|
||||
tdSql.execute('insert into t4 values (%d , 2)' %(t0+i))
|
||||
|
||||
for i in range(200, 5000):
|
||||
tdSql.execute('insert into t4 values (%d , 2)' %(t0+i))
|
||||
|
||||
for i in range(100):
|
||||
tdSql.execute('insert into t4 values (%d , 1)' %(t0+i+5000))
|
||||
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t4;')
|
||||
for i in range(100):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(100, 200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(200, 5000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(5000, 5200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
print('check query result after restart')
|
||||
self.restart_taosd('db')
|
||||
tdSql.query('select * from db.t4;')
|
||||
for i in range(100):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(100, 200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(200, 5000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(5000, 5200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
print("==================================5 start")
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
tdSql.execute('create table t5 (ts timestamp, a int)')
|
||||
insert_rows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % insert_rows)
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t5 values (%d , 1)' %(t0+i))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t5 values (%d , 1)' %(t0+i+5000))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(100, 200):
|
||||
tdSql.execute('insert into t5 values (%d , 2)' %(t0+i))
|
||||
|
||||
for i in range(200, 5000):
|
||||
tdSql.execute('insert into t5 values (%d , 2)' %(t0+i))
|
||||
|
||||
for i in range(100, 200):
|
||||
tdSql.execute('insert into t5 values (%d , 2)' %(t0+i+5000))
|
||||
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t5;')
|
||||
for i in range(100):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(100, 5000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(5000, 5100):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(5100, 5200):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
|
||||
print('check query result after restart')
|
||||
self.restart_taosd('db')
|
||||
tdSql.query('select * from db.t5;')
|
||||
for i in range(100):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(100, 5000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(5000, 5100):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(5100, 5200):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
|
||||
print("==================================6 start")
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
tdSql.execute('create table t6 (ts timestamp, a int)')
|
||||
insert_rows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % insert_rows)
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t6 values (%d , 1)' %(t0+i))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t6 values (%d , 1)' %(t0+i+5000))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(-1000, 10000):
|
||||
tdSql.execute('insert into t6 values (%d , 2)' %(t0+i))
|
||||
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t6;')
|
||||
tdSql.checkRows(11000)
|
||||
for i in range(11000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
|
||||
print('check query result after restart')
|
||||
self.restart_taosd('db')
|
||||
tdSql.query('select * from db.t6;')
|
||||
tdSql.checkRows(11000)
|
||||
for i in range(11000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
|
||||
|
||||
print("==================================7 start")
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
tdSql.execute('create table t7 (ts timestamp, a int)')
|
||||
insert_rows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % insert_rows)
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t7 values (%d , 1)' %(t0+i))
|
||||
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t7 values (%d , 1)' %(t0+i+5000))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(-1000, 10000):
|
||||
tdSql.execute('insert into t7 values (%d , 2)' %(t0+i))
|
||||
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t7;')
|
||||
tdSql.checkRows(11000)
|
||||
for i in range(11000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
|
||||
print('check query result after restart')
|
||||
self.restart_taosd('db')
|
||||
tdSql.query('select * from db.t7;')
|
||||
tdSql.checkRows(11000)
|
||||
for i in range(11000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,384 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
import time
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
|
||||
def restart_taosd(self,db):
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.startWithoutSleep(1)
|
||||
tdSql.execute("use %s;" % db)
|
||||
|
||||
def date_to_timestamp_microseconds(self, date):
|
||||
datetime_obj = datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f")
|
||||
obj_stamp = int(time.mktime(datetime_obj.timetuple()) * 1000.0 + datetime_obj.microsecond / 1000.0)
|
||||
return obj_stamp
|
||||
|
||||
def timestamp_microseconds_to_date(self, timestamp):
|
||||
d = datetime.datetime.fromtimestamp(timestamp/1000)
|
||||
str1 = d.strftime("%Y-%m-%d %H:%M:%S.%f")
|
||||
return str1
|
||||
|
||||
|
||||
|
||||
def run(self):
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
sql = 'reset query cache'
|
||||
tdSql.execute(sql)
|
||||
sql = 'drop database if exists db'
|
||||
tdSql.execute(sql)
|
||||
sql = 'create database db update 0 days 30;'
|
||||
tdSql.execute(sql)
|
||||
sql = 'use db;'
|
||||
tdSql.execute(sql)
|
||||
tdSql.execute('create table t1 (ts timestamp, a int)')
|
||||
|
||||
|
||||
print("==================================1 start")
|
||||
insert_rows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % insert_rows)
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t1 values (%d , 1)' %(t0+i))
|
||||
print("==========step2")
|
||||
print("restart to commit ")
|
||||
self.restart_taosd('db')
|
||||
|
||||
print('check query result after restart')
|
||||
tdSql.query('select * from db.t1;')
|
||||
for i in range(insert_rows):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
print("==========step3")
|
||||
print('insert data')
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t1 values (%d , 1)' %(t0+i+5000))
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t1;')
|
||||
for i in range(insert_rows, insert_rows*2):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
self.restart_taosd('db')
|
||||
print('check query result after restart')
|
||||
tdSql.query('select * from db.t1;')
|
||||
for i in range(insert_rows, insert_rows*2):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
print("==========step4")
|
||||
print('insert data')
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t1 values (%d , 2)' %(t0+i))
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t1 values (%d , 1)' %(t0+i+5000))
|
||||
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t1;')
|
||||
print(tdSql.queryResult)
|
||||
for i in range(insert_rows):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(insert_rows, insert_rows*2):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
print('check query result after restart')
|
||||
self.restart_taosd('db')
|
||||
tdSql.query('select * from db.t1;')
|
||||
# print(tdSql.queryResult)
|
||||
for i in range(insert_rows):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(insert_rows, insert_rows*2):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
print("==================================2 start")
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
tdSql.execute('create table t2 (ts timestamp, a int)')
|
||||
insert_rows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % insert_rows)
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t2 values (%d , 1)' %(t0+i))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t2 values (%d , 1)' %(t0+i+5000))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for k in range(10):
|
||||
for i in range(10):
|
||||
tdSql.execute('insert into t2 values (%d , 1)' %(t0 + 200 + k * 10 + i))
|
||||
# print('insert into t2 values (%d , 1)' %(t0 + 200 + k * 10 + i))
|
||||
|
||||
|
||||
print("==========step2")
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t2;')
|
||||
for i in range(insert_rows*2+100):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
# print(tdSql.queryResult)
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
print('check query result after restart')
|
||||
tdSql.query('select * from db.t2;')
|
||||
for i in range(insert_rows*2+100):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
|
||||
print("==================================3 start")
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
tdSql.execute('create table t3 (ts timestamp, a int)')
|
||||
insert_rows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % insert_rows)
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t3 values (%d , 1)' %(t0+i))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t3 values (%d , 1)' %(t0+i+5000))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(5200):
|
||||
tdSql.execute('insert into t3 values (%d , 2)' %(t0+i))
|
||||
|
||||
print("==========step2")
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t3;')
|
||||
for i in range(200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(200, 5000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(5000, 5200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
# print(tdSql.queryResult)
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
print('check query result after restart')
|
||||
tdSql.query('select * from db.t3;')
|
||||
for i in range(200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(200, 5000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(5000, 5200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
print("==================================4 start")
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
tdSql.execute('create table t4 (ts timestamp, a int)')
|
||||
insert_rows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % insert_rows)
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t4 values (%d , 1)' %(t0+i))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t4 values (%d , 1)' %(t0+i+5000))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(100):
|
||||
tdSql.execute('insert into t4 values (%d , 2)' %(t0+i))
|
||||
|
||||
for i in range(200, 5000):
|
||||
tdSql.execute('insert into t4 values (%d , 2)' %(t0+i))
|
||||
|
||||
for i in range(100):
|
||||
tdSql.execute('insert into t4 values (%d , 1)' %(t0+i+5000))
|
||||
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t4;')
|
||||
for i in range(200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(200, 5000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(5000, 5200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
print('check query result after restart')
|
||||
self.restart_taosd('db')
|
||||
tdSql.query('select * from db.t4;')
|
||||
for i in range(200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(200, 5000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(5000, 5200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
#
|
||||
print("==================================5 start")
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
tdSql.execute('create table t5 (ts timestamp, a int)')
|
||||
insert_rows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % insert_rows)
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t5 values (%d , 1)' %(t0+i))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t5 values (%d , 1)' %(t0+i+5000))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(100, 200):
|
||||
tdSql.execute('insert into t5 values (%d , 2)' %(t0+i))
|
||||
|
||||
for i in range(200, 5000):
|
||||
tdSql.execute('insert into t5 values (%d , 2)' %(t0+i))
|
||||
|
||||
for i in range(100, 200):
|
||||
tdSql.execute('insert into t5 values (%d , 2)' %(t0+i+5000))
|
||||
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t5;')
|
||||
for i in range(200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(200, 5000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(5000, 5200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
print('check query result after restart')
|
||||
self.restart_taosd('db')
|
||||
tdSql.query('select * from db.t5;')
|
||||
for i in range(200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(200, 5000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(5000, 5200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
print("==================================6 start")
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
tdSql.execute('create table t6 (ts timestamp, a int)')
|
||||
insert_rows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % insert_rows)
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t6 values (%d , 1)' %(t0+i))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t6 values (%d , 1)' %(t0+i+5000))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(-1000, 10000):
|
||||
tdSql.execute('insert into t6 values (%d , 2)' %(t0+i))
|
||||
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t6;')
|
||||
tdSql.checkRows(11000)
|
||||
for i in range(1000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(1000,1200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(1200,6000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(6000,6200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(6200, 11000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
|
||||
print('check query result after restart')
|
||||
self.restart_taosd('db')
|
||||
tdSql.query('select * from db.t6;')
|
||||
tdSql.checkRows(11000)
|
||||
for i in range(1000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(1000,1200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(1200,6000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(6000,6200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(6200, 11000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
|
||||
|
||||
print("==================================7 start")
|
||||
print("==========step1")
|
||||
print("create table && insert data")
|
||||
tdSql.execute('create table t7 (ts timestamp, a int)')
|
||||
insert_rows = 200
|
||||
t0 = 1603152000000
|
||||
tdLog.info("insert %d rows" % insert_rows)
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t7 values (%d , 1)' %(t0+i))
|
||||
|
||||
for i in range(insert_rows):
|
||||
tdSql.execute('insert into t7 values (%d , 1)' %(t0+i+5000))
|
||||
print('restart to commit')
|
||||
self.restart_taosd('db')
|
||||
|
||||
for i in range(-1000, 10000):
|
||||
tdSql.execute('insert into t7 values (%d , 2)' %(t0+i))
|
||||
|
||||
print('check query result before restart')
|
||||
tdSql.query('select * from db.t7;')
|
||||
tdSql.checkRows(11000)
|
||||
for i in range(1000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(1000,1200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(1200,6000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(6000,6200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(6200, 11000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
|
||||
print('check query result after restart')
|
||||
self.restart_taosd('db')
|
||||
tdSql.query('select * from db.t7;')
|
||||
tdSql.checkRows(11000)
|
||||
for i in range(1000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(1000,1200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(1200,6000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(6000,6200):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(6200, 11000):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,309 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import taos
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor())
|
||||
|
||||
self.ts = 1603152000000
|
||||
|
||||
def restartTaosd(self):
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.startWithoutSleep(1)
|
||||
tdSql.execute("use db")
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
|
||||
print("==============step 1: UPDATE THE LAST RECORD REPEATEDLY")
|
||||
tdSql.execute("create table t1 (ts timestamp, a int)")
|
||||
|
||||
for i in range(5):
|
||||
tdSql.execute("insert into t1 values(%d, %d)" % (self.ts, i))
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 0)
|
||||
|
||||
print("==============step 2: UPDATE THE WHOLE LAST BLOCK")
|
||||
tdSql.execute("create table t2 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t2 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t2")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t2 values(%d, 2)" % (self.ts + i))
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t2")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t2")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
print("==============step 3: UPDATE PART OF THE LAST BLOCK")
|
||||
tdSql.execute("create table t3 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t3 values(%d, 1)" % (self.ts + i))
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t3")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
for i in range(25):
|
||||
tdSql.execute("insert into t3 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t3")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t3")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
print("==============step 4: UPDATE AND INSERT APPEND AT END OF DATA")
|
||||
tdSql.execute("create table t4 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t4 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t4")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t4")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
for i in range(25):
|
||||
tdSql.execute("insert into t4 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
for i in range(50, 60):
|
||||
tdSql.execute("insert into t4 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t4")
|
||||
tdSql.checkRows(60)
|
||||
tdSql.query("select sum(a) from t4")
|
||||
tdSql.checkData(0, 0, 70)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t4")
|
||||
tdSql.checkRows(60)
|
||||
tdSql.query("select sum(a) from t4")
|
||||
tdSql.checkData(0, 0, 70)
|
||||
|
||||
print("==============step 5: UPDATE AND INSERT PREPEND SOME DATA")
|
||||
tdSql.execute("create table t5 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t5 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t5")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
for i in range(-10, 0):
|
||||
tdSql.execute("insert into t5 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
for i in range(25):
|
||||
tdSql.execute("insert into t5 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(60)
|
||||
tdSql.query("select sum(a) from t5")
|
||||
tdSql.checkData(0, 0, 70)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(60)
|
||||
tdSql.query("select sum(a) from t5")
|
||||
tdSql.checkData(0, 0, 70)
|
||||
|
||||
for i in range(-10, 0):
|
||||
tdSql.execute("insert into t5 values(%d, 3)" % (self.ts + i))
|
||||
|
||||
for i in range(25, 50):
|
||||
tdSql.execute("insert into t5 values(%d, 3)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(60)
|
||||
tdSql.query("select sum(a) from t5")
|
||||
tdSql.checkData(0, 0, 70)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(60)
|
||||
tdSql.query("select sum(a) from t5")
|
||||
tdSql.checkData(0, 0, 70)
|
||||
|
||||
|
||||
print("==============step 6: INSERT AHEAD A LOT OF DATA")
|
||||
tdSql.execute("create table t6 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t6 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t6")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
for i in range(-1000, 0):
|
||||
tdSql.execute("insert into t6 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(1050)
|
||||
tdSql.query("select sum(a) from t6")
|
||||
tdSql.checkData(0, 0, 2050)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(1050)
|
||||
tdSql.query("select sum(a) from t6")
|
||||
tdSql.checkData(0, 0, 2050)
|
||||
|
||||
print("==============step 7: INSERT AHEAD A LOT AND UPDATE")
|
||||
tdSql.execute("create table t7 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t7 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t7")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t7")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
for i in range(-1000, 25):
|
||||
tdSql.execute("insert into t7 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t7")
|
||||
tdSql.checkRows(1050)
|
||||
tdSql.query("select sum(a) from t7")
|
||||
tdSql.checkData(0, 0, 2050)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t7")
|
||||
tdSql.checkRows(1050)
|
||||
tdSql.query("select sum(a) from t7")
|
||||
tdSql.checkData(0, 0, 2050)
|
||||
|
||||
print("==============step 8: INSERT AFTER A LOT AND UPDATE")
|
||||
tdSql.execute("create table t8 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t8 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t8")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t8")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
for i in range(25, 6000):
|
||||
tdSql.execute("insert into t8 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t8")
|
||||
tdSql.checkRows(6000)
|
||||
tdSql.query("select sum(a) from t8")
|
||||
tdSql.checkData(0, 0, 11950)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t8")
|
||||
tdSql.checkRows(6000)
|
||||
tdSql.query("select sum(a) from t8")
|
||||
tdSql.checkData(0, 0, 11950)
|
||||
|
||||
print("==============step 9: UPDATE ONLY MIDDLE")
|
||||
tdSql.execute("create table t9 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t9 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t9")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t9")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
for i in range(20, 30):
|
||||
tdSql.execute("insert into t9 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t9")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t9")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t9")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t9")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
print("==============step 10: A LOT OF DATA COVER THE WHOLE BLOCK")
|
||||
tdSql.execute("create table t10 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t10 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t10")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t10")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
for i in range(-4000, 4000):
|
||||
tdSql.execute("insert into t10 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t10")
|
||||
tdSql.checkRows(8000)
|
||||
tdSql.query("select sum(a) from t10")
|
||||
tdSql.checkData(0, 0, 15950)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t10")
|
||||
tdSql.checkRows(8000)
|
||||
tdSql.query("select sum(a) from t10")
|
||||
tdSql.checkData(0, 0, 15950)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,321 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import taos
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor())
|
||||
|
||||
self.ts = 1603152000000
|
||||
|
||||
def restartTaosd(self):
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.startWithoutSleep(1)
|
||||
tdSql.execute("use udb")
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
|
||||
tdSql.execute("create database udb update 1 days 30")
|
||||
tdSql.execute("use udb")
|
||||
|
||||
print("==============step 1: UPDATE THE LAST RECORD REPEATEDLY")
|
||||
tdSql.execute("create table t1 (ts timestamp, a int)")
|
||||
|
||||
for i in range(5):
|
||||
tdSql.execute("insert into t1 values(%d, %d)" % (self.ts, i))
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, i)
|
||||
|
||||
print("==============step 2: UPDATE THE WHOLE LAST BLOCK")
|
||||
tdSql.execute("create table t2 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t2 values(%d, 1)" % (self.ts + i))
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(50)
|
||||
for i in range(50):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t2 values(%d, 2)" % (self.ts + i))
|
||||
tdSql.query("select * from t2")
|
||||
for i in range(50):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(50)
|
||||
for i in range(50):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
|
||||
print("==============step 3: UPDATE PART OF THE LAST BLOCK")
|
||||
tdSql.execute("create table t3 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t3 values(%d, 1)" % (self.ts + i))
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(50)
|
||||
for i in range(50):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
for i in range(25):
|
||||
tdSql.execute("insert into t3 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t3")
|
||||
for i in range(25):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(25, 50):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t3")
|
||||
tdSql.checkRows(50)
|
||||
for i in range(25):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(25, 50):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
print("==============step 4: UPDATE AND INSERT APPEND AT END OF DATA")
|
||||
tdSql.execute("create table t4 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t4 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t4")
|
||||
tdSql.checkRows(50)
|
||||
for i in range(50):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
for i in range(25):
|
||||
tdSql.execute("insert into t4 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
for i in range(50, 60):
|
||||
tdSql.execute("insert into t4 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t4")
|
||||
tdSql.checkRows(60)
|
||||
for i in range(25):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(25, 50):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(50, 60):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t4")
|
||||
tdSql.checkRows(60)
|
||||
for i in range(25):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
for i in range(25, 50):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
for i in range(50, 60):
|
||||
tdSql.checkData(i, 1, 2)
|
||||
|
||||
print("==============step 5: UPDATE AND INSERT PREPEND SOME DATA")
|
||||
tdSql.execute("create table t5 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t5 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(50)
|
||||
for i in range(50):
|
||||
tdSql.checkData(i, 1, 1)
|
||||
|
||||
for i in range(-10, 0):
|
||||
tdSql.execute("insert into t5 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
for i in range(25):
|
||||
tdSql.execute("insert into t5 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(60)
|
||||
tdSql.query("select sum(a) from t5")
|
||||
tdSql.checkData(0, 0, 95)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(60)
|
||||
tdSql.query("select sum(a) from t5")
|
||||
tdSql.checkData(0, 0, 95)
|
||||
|
||||
for i in range(-10, 0):
|
||||
tdSql.execute("insert into t5 values(%d, 3)" % (self.ts + i))
|
||||
|
||||
for i in range(25, 50):
|
||||
tdSql.execute("insert into t5 values(%d, 3)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(60)
|
||||
tdSql.query("select sum(a) from t5")
|
||||
tdSql.checkData(0, 0, 155)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t5")
|
||||
tdSql.checkRows(60)
|
||||
tdSql.query("select sum(a) from t5")
|
||||
tdSql.checkData(0, 0, 155)
|
||||
|
||||
|
||||
print("==============step 6: INSERT AHEAD A LOT OF DATA")
|
||||
tdSql.execute("create table t6 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t6 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t6")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
for i in range(-1000, 0):
|
||||
tdSql.execute("insert into t6 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(1050)
|
||||
tdSql.query("select sum(a) from t6")
|
||||
tdSql.checkData(0, 0, 2050)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t6")
|
||||
tdSql.checkRows(1050)
|
||||
tdSql.query("select sum(a) from t6")
|
||||
tdSql.checkData(0, 0, 2050)
|
||||
|
||||
print("==============step 7: INSERT AHEAD A LOT AND UPDATE")
|
||||
tdSql.execute("create table t7 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t7 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t7")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t7")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
for i in range(-1000, 25):
|
||||
tdSql.execute("insert into t7 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t7")
|
||||
tdSql.checkRows(1050)
|
||||
tdSql.query("select sum(a) from t7")
|
||||
tdSql.checkData(0, 0, 2075)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t7")
|
||||
tdSql.checkRows(1050)
|
||||
tdSql.query("select sum(a) from t7")
|
||||
tdSql.checkData(0, 0, 2075)
|
||||
|
||||
print("==============step 8: INSERT AFTER A LOT AND UPDATE")
|
||||
tdSql.execute("create table t8 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t8 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t8")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t8")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
for i in range(25, 6000):
|
||||
tdSql.execute("insert into t8 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t8")
|
||||
tdSql.checkRows(6000)
|
||||
tdSql.query("select sum(a) from t8")
|
||||
tdSql.checkData(0, 0, 11975)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t8")
|
||||
tdSql.checkRows(6000)
|
||||
tdSql.query("select sum(a) from t8")
|
||||
tdSql.checkData(0, 0, 11975)
|
||||
|
||||
print("==============step 9: UPDATE ONLY MIDDLE")
|
||||
tdSql.execute("create table t9 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t9 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t9")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t9")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
for i in range(20, 30):
|
||||
tdSql.execute("insert into t9 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t9")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t9")
|
||||
tdSql.checkData(0, 0, 60)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t9")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t9")
|
||||
tdSql.checkData(0, 0, 60)
|
||||
|
||||
print("==============step 10: A LOT OF DATA COVER THE WHOLE BLOCK")
|
||||
tdSql.execute("create table t10 (ts timestamp, a int)")
|
||||
|
||||
for i in range(50):
|
||||
tdSql.execute("insert into t10 values(%d, 1)" % (self.ts + i))
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t10")
|
||||
tdSql.checkRows(50)
|
||||
tdSql.query("select sum(a) from t10")
|
||||
tdSql.checkData(0, 0, 50)
|
||||
|
||||
for i in range(-4000, 4000):
|
||||
tdSql.execute("insert into t10 values(%d, 2)" % (self.ts + i))
|
||||
|
||||
tdSql.query("select * from t10")
|
||||
tdSql.checkRows(8000)
|
||||
tdSql.query("select sum(a) from t10")
|
||||
tdSql.checkData(0, 0, 16000)
|
||||
|
||||
self.restartTaosd()
|
||||
tdSql.query("select * from t10")
|
||||
tdSql.checkRows(8000)
|
||||
tdSql.query("select sum(a) from t10")
|
||||
tdSql.checkData(0, 0, 16000)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,70 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import os
|
||||
import taos
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor())
|
||||
|
||||
def createOldDir(self):
|
||||
oldDir = tdDnodes.getDnodesRootDir() + "dnode1/data/vnode/vnode2/wal/old"
|
||||
os.system("sudo mkdir -p %s" % oldDir)
|
||||
|
||||
def createOldDirAndAddWal(self):
|
||||
oldDir = tdDnodes.getDnodesRootDir() + "dnode1/data/vnode/vnode2/wal/old"
|
||||
os.system("sudo echo 'test' >> %s/wal" % oldDir)
|
||||
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
|
||||
tdSql.execute("create table t1(ts timestamp, a int)")
|
||||
tdSql.execute("insert into t1 values(now, 1)")
|
||||
|
||||
# create old dir only
|
||||
self.createOldDir()
|
||||
os.system("sudo kill -9 $(pgrep taosd)")
|
||||
tdDnodes.start(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 1)
|
||||
|
||||
# create old dir and add wal under old dir
|
||||
self.createOldDir()
|
||||
self.createOldDirAndAddWal()
|
||||
os.system("sudo kill -9 $(pgrep taosd)")
|
||||
tdDnodes.start(1)
|
||||
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 1, 1)
|
||||
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -81,7 +81,7 @@ print =============== step2 - no db
|
|||
#11
|
||||
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/rest/sql
|
||||
print 11-> $system_content
|
||||
if $system_content != @{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep1,keep2,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","precision","status"],"data":[],"rows":0}@ then
|
||||
if $system_content != @{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep1,keep2,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","precision","update","status"],"data":[],"rows":0}@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
|
|
@ -134,66 +134,8 @@ sql select join_mt0.ts, join_mt1.t1, join_mt0.t1, join_mt1.tbname, join_mt0.tbna
|
|||
|
||||
#1970-01-01 08:01:40.800 | 10 | 45.000000000 | 0 | true | false | 0 |
|
||||
#1970-01-01 08:01:40.790 | 10 | 945.000000000 | 90 | true | true | 0 |
|
||||
sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7), first(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1 order by join_mt0.ts desc limit 20 offset 19;
|
||||
if $rows != 20 then
|
||||
return -1
|
||||
endi
|
||||
sql_error select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7), first(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1 order by join_mt0.ts desc limit 20 offset 19;
|
||||
|
||||
if $data00 != @70-01-01 08:01:40.800@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 45.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data03 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data04 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data05 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data06 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != @70-01-01 08:01:40.790@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data12 != 945.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data13 != 90 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data14 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data15 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data16 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(join_mt0.c1), sum(join_mt0.c2)/count(*), avg(c2), first(join_mt0.c5), last(c7) from join_mt0 interval(10a) group by join_mt0.t1 order by join_mt0.ts desc;
|
||||
if $rows != 100 then
|
||||
|
@ -261,59 +203,9 @@ if $data16 != 2 then
|
|||
endi
|
||||
|
||||
# this function will cause shell crash
|
||||
sql select count(join_mt0.c1), first(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1 order by join_mt0.ts desc;
|
||||
if $rows != 100 then
|
||||
return -1
|
||||
endi
|
||||
sql_error select count(join_mt0.c1), first(join_mt0.c1) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1 order by join_mt0.ts desc;
|
||||
|
||||
if $data00 != @70-01-01 08:01:40.990@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 90 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data03 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data12 != 80 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data13 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select last(join_mt1.c7), first(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10m) group by join_mt0.t1 order by join_mt0.ts asc;
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != @70-01-01 08:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data02 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data03 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql_error select last(join_mt1.c7), first(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10m) group by join_mt0.t1 order by join_mt0.ts asc;
|
||||
|
||||
sql_error select count(join_mt0.c1), first(join_mt0.c1)-last(join_mt1.c1), first(join_mt1.c9) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts;", NULL);
|
||||
sql select count(join_mt0.c1), first(join_mt0.c1)/count(*), first(join_mt1.c9) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts;", NULL);
|
||||
|
|
|
@ -22,12 +22,12 @@ $i = 0
|
|||
|
||||
sql use $db
|
||||
|
||||
sql create table cpustrm as select count(*), avg(cpu_taosd), max(cpu_taosd), min(cpu_taosd), avg(cpu_system), max(cpu_cores), min(cpu_cores), last(cpu_cores) from log.dn1 interval(4s) sliding(2s)
|
||||
sql create table memstrm as select count(*), avg(mem_taosd), max(mem_taosd), min(mem_taosd), avg(mem_system), first(mem_total), last(mem_total) from log.dn1 interval(4s) sliding(2s)
|
||||
sql create table diskstrm as select count(*), avg(disk_used), last(disk_used), avg(disk_total), first(disk_total) from log.dn1 interval(4s) sliding(2s)
|
||||
sql create table bandstrm as select count(*), avg(band_speed), last(band_speed) from log.dn1 interval(4s) sliding(2s)
|
||||
sql create table reqstrm as select count(*), avg(req_http), last(req_http), avg(req_select), last(req_select), avg(req_insert), last(req_insert) from log.dn1 interval(4s) sliding(2s)
|
||||
sql create table iostrm as select count(*), avg(io_read), last(io_read), avg(io_write), last(io_write) from log.dn1 interval(4s) sliding(2s)
|
||||
sql create table cpustrm as select count(*), avg(cpu_taosd), max(cpu_taosd), min(cpu_taosd), avg(cpu_system), max(cpu_cores), min(cpu_cores), last(cpu_cores) from log.dn1 interval(4s)
|
||||
sql create table memstrm as select count(*), avg(mem_taosd), max(mem_taosd), min(mem_taosd), avg(mem_system), first(mem_total), last(mem_total) from log.dn1 interval(4s)
|
||||
sql create table diskstrm as select count(*), avg(disk_used), last(disk_used), avg(disk_total), first(disk_total) from log.dn1 interval(4s)
|
||||
sql create table bandstrm as select count(*), avg(band_speed), last(band_speed) from log.dn1 interval(4s)
|
||||
sql create table reqstrm as select count(*), avg(req_http), last(req_http), avg(req_select), last(req_select), avg(req_insert), last(req_insert) from log.dn1 interval(4s)
|
||||
sql create table iostrm as select count(*), avg(io_read), last(io_read), avg(io_write), last(io_write) from log.dn1 interval(4s)
|
||||
sleep 120000
|
||||
sql select * from cpustrm
|
||||
if $rows <= 0 then
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
|
||||
print ============== deploy
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
sleep 3001
|
||||
sql connect
|
||||
|
||||
sql create database d1
|
||||
sql use d1
|
||||
|
||||
sql create table t1 (ts timestamp, i int)
|
||||
sql insert into t1 values(now, 1);
|
||||
|
||||
print =============== step3
|
||||
sleep 3000
|
||||
sql select * from t1;
|
||||
print rows: $rows
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGKILL
|
||||
sleep 3000
|
||||
|
||||
print =============== step4
|
||||
system sh/exec.sh -n dnode1 -s start -x SIGKILL
|
||||
sleep 3000
|
||||
sql select * from t1;
|
||||
print rows: $rows
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGKILL
|
||||
sleep 3000
|
||||
|
||||
print =============== step5
|
||||
system sh/exec.sh -n dnode1 -s start -x SIGKILL
|
||||
sleep 3000
|
||||
sql select * from t1;
|
||||
print rows: $rows
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGKILL
|
||||
sleep 3000
|
||||
|
||||
print =============== step6
|
||||
system sh/exec.sh -n dnode1 -s start -x SIGKILL
|
||||
sleep 3000
|
||||
sql select * from t1;
|
||||
print rows: $rows
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGKILL
|
||||
sleep 3000
|
||||
|
||||
print =============== step7
|
||||
system sh/exec.sh -n dnode1 -s start -x SIGKILL
|
||||
sleep 3000
|
||||
sql select * from t1;
|
||||
print rows: $rows
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGKILL
|
||||
sleep 3000
|
||||
|
||||
print =============== step8
|
||||
system sh/exec.sh -n dnode1 -s start -x SIGKILL
|
||||
sleep 3000
|
||||
sql select * from t1;
|
||||
print rows: $rows
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGKILL
|
|
@ -0,0 +1,124 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/deploy.sh -n dnode2 -i 2
|
||||
system sh/deploy.sh -n dnode3 -i 3
|
||||
|
||||
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3
|
||||
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3
|
||||
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3
|
||||
|
||||
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
|
||||
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
|
||||
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
|
||||
|
||||
system sh/cfg.sh -n dnode1 -c http -v 1
|
||||
system sh/cfg.sh -n dnode2 -c http -v 1
|
||||
system sh/cfg.sh -n dnode3 -c http -v 1
|
||||
|
||||
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20000
|
||||
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 20000
|
||||
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 20000
|
||||
|
||||
system sh/cfg.sh -n dnode1 -c replica -v 3
|
||||
system sh/cfg.sh -n dnode2 -c replica -v 3
|
||||
system sh/cfg.sh -n dnode3 -c replica -v 3
|
||||
|
||||
system sh/cfg.sh -n dnode1 -c maxSQLLength -v 940032
|
||||
system sh/cfg.sh -n dnode2 -c maxSQLLength -v 940032
|
||||
system sh/cfg.sh -n dnode3 -c maxSQLLength -v 940032
|
||||
|
||||
print ============== deploy
|
||||
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
sleep 5001
|
||||
sql connect
|
||||
|
||||
sql create dnode $hostname2
|
||||
sql create dnode $hostname3
|
||||
system sh/exec.sh -n dnode2 -s start
|
||||
system sh/exec.sh -n dnode3 -s start
|
||||
|
||||
print =============== step1
|
||||
$x = 0
|
||||
show1:
|
||||
$x = $x + 1
|
||||
sleep 2000
|
||||
if $x == 5 then
|
||||
return -1
|
||||
endi
|
||||
sql show mnodes -x show1
|
||||
$mnode1Role = $data2_1
|
||||
print mnode1Role $mnode1Role
|
||||
$mnode2Role = $data2_2
|
||||
print mnode2Role $mnode2Role
|
||||
$mnode3Role = $data2_3
|
||||
print mnode3Role $mnode3Role
|
||||
|
||||
if $mnode1Role != master then
|
||||
goto show1
|
||||
endi
|
||||
if $mnode2Role != slave then
|
||||
goto show1
|
||||
endi
|
||||
if $mnode3Role != slave then
|
||||
goto show1
|
||||
endi
|
||||
|
||||
print =============== step2
|
||||
sql create database d1 replica 3
|
||||
sql use d1
|
||||
|
||||
sql create table table_rest (ts timestamp, i int)
|
||||
print sql length is 870KB
|
||||
restful d1 table_rest 1591072800 30000
|
||||
restful d1 table_rest 1591172800 30000
|
||||
restful d1 table_rest 1591272800 30000
|
||||
restful d1 table_rest 1591372800 30000
|
||||
restful d1 table_rest 1591472800 30000
|
||||
restful d1 table_rest 1591572800 30000
|
||||
restful d1 table_rest 1591672800 30000
|
||||
restful d1 table_rest 1591772800 30000
|
||||
restful d1 table_rest 1591872800 30000
|
||||
restful d1 table_rest 1591972800 30000
|
||||
|
||||
sql select * from table_rest;
|
||||
print rows: $rows
|
||||
if $rows != 300000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step3
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
sleep 5000
|
||||
sql select * from table_rest;
|
||||
print rows: $rows
|
||||
if $rows != 300000 then
|
||||
return -1
|
||||
endi
|
||||
system sh/exec.sh -n dnode1 -s start -x SIGINT
|
||||
sleep 5000
|
||||
|
||||
print =============== step4
|
||||
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
||||
sleep 5000
|
||||
sql select * from table_rest;
|
||||
print rows: $rows
|
||||
if $rows != 300000 then
|
||||
return -1
|
||||
endi
|
||||
system sh/exec.sh -n dnode2 -s start -x SIGINT
|
||||
sleep 5000
|
||||
|
||||
print =============== step5
|
||||
system sh/exec.sh -n dnode3 -s stop -x SIGINT
|
||||
sleep 5000
|
||||
sql select * from table_rest;
|
||||
print rows: $rows
|
||||
if $rows != 300000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode3 -s stop -x SIGINT
|
|
@ -236,6 +236,9 @@ cd ../../../debug; make
|
|||
./test.sh -f general/vector/table_query.sim
|
||||
./test.sh -f general/vector/table_time.sim
|
||||
|
||||
./test.sh -f general/wal/sync.sim
|
||||
./test.sh -f general/wal/kill.sim
|
||||
|
||||
./test.sh -f unique/account/account_create.sim
|
||||
./test.sh -f unique/account/account_delete.sim
|
||||
./test.sh -f unique/account/account_len.sim
|
||||
|
|
|
@ -26,7 +26,12 @@ function runPyCaseOneByOne {
|
|||
while read -r line; do
|
||||
if [[ $line =~ ^python.* ]]; then
|
||||
if [[ $line != *sleep* ]]; then
|
||||
|
||||
if [[ $line =~ '-r' ]];then
|
||||
case=`echo $line|awk '{print $4}'`
|
||||
else
|
||||
case=`echo $line|awk '{print $NF}'`
|
||||
fi
|
||||
start_time=`date +%s`
|
||||
$line > /dev/null 2>&1 && \
|
||||
echo -e "${GREEN}$case success${NC}" | tee -a pytest-out.log || \
|
||||
|
|
|
@ -100,7 +100,7 @@ typedef struct _cmd_t {
|
|||
int16_t cmdno;
|
||||
int16_t nlen;
|
||||
char name[MAX_SIM_CMD_NAME_LEN];
|
||||
bool (*parseCmd)(char *, struct _cmd_t *, int);
|
||||
bool (*parseCmd)(char *, struct _cmd_t *, int32_t);
|
||||
bool (*executeCmd)(struct _script_t *script, char *option);
|
||||
struct _cmd_t *next;
|
||||
} SCommand;
|
||||
|
@ -111,7 +111,7 @@ typedef struct {
|
|||
int16_t errorJump; // sql jump flag, while '-x' exist in sql cmd, this flag
|
||||
// will be SQL_JUMP_TRUE, otherwise is SQL_JUMP_FALSE */
|
||||
int16_t lineNum; // correspodning line number in original file
|
||||
int optionOffset; // relative option offset
|
||||
int32_t optionOffset;// relative option offset
|
||||
} SCmdLine;
|
||||
|
||||
typedef struct _var_t {
|
||||
|
@ -121,45 +121,42 @@ typedef struct _var_t {
|
|||
} SVariable;
|
||||
|
||||
typedef struct _script_t {
|
||||
int type;
|
||||
int32_t type;
|
||||
bool killed;
|
||||
|
||||
void * taos;
|
||||
char rows[12]; // number of rows data retrieved
|
||||
char data[MAX_QUERY_ROW_NUM][MAX_QUERY_COL_NUM]
|
||||
[MAX_QUERY_VALUE_LEN]; // query results
|
||||
char data[MAX_QUERY_ROW_NUM][MAX_QUERY_COL_NUM][MAX_QUERY_VALUE_LEN]; // query results
|
||||
char system_exit_code[12];
|
||||
char system_ret_content[MAX_SYSTEM_RESULT_LEN];
|
||||
|
||||
int varLen;
|
||||
int linePos; // current cmd position
|
||||
int numOfLines; // number of lines in the script
|
||||
int bgScriptLen;
|
||||
int32_t varLen;
|
||||
int32_t linePos; // current cmd position
|
||||
int32_t numOfLines; // number of lines in the script
|
||||
int32_t bgScriptLen;
|
||||
char fileName[MAX_FILE_NAME_LEN]; // script file name
|
||||
char error[MAX_ERROR_LEN];
|
||||
char * optionBuffer;
|
||||
SCmdLine *lines; // command list
|
||||
SVariable variables[MAX_VAR_LEN];
|
||||
struct _script_t *bgScripts[MAX_BACKGROUND_SCRIPT_NUM];
|
||||
pthread_t bgPid;
|
||||
char auth[128];
|
||||
struct _script_t *bgScripts[MAX_BACKGROUND_SCRIPT_NUM];
|
||||
} SScript;
|
||||
|
||||
extern SScript *simScriptList[MAX_MAIN_SCRIPT_NUM];
|
||||
extern SCommand simCmdList[];
|
||||
extern int simScriptPos;
|
||||
extern int simScriptSucced;
|
||||
extern int simDebugFlag;
|
||||
extern int32_t simScriptPos;
|
||||
extern int32_t simScriptSucced;
|
||||
extern int32_t simDebugFlag;
|
||||
extern char tsScriptDir[];
|
||||
extern bool simAsyncQuery;
|
||||
|
||||
SScript *simParseScript(char *fileName);
|
||||
|
||||
SScript *simProcessCallOver(SScript *script);
|
||||
void * simExecuteScript(void *script);
|
||||
void simInitsimCmdList();
|
||||
bool simSystemInit();
|
||||
void simSystemCleanUp();
|
||||
char *simGetVariable(SScript *script, char *varName, int varLen);
|
||||
char * simGetVariable(SScript *script, char *varName, int32_t varLen);
|
||||
bool simExecuteExpCmd(SScript *script, char *option);
|
||||
bool simExecuteTestCmd(SScript *script, char *option);
|
||||
bool simExecuteGotoCmd(SScript *script, char *option);
|
||||
|
|
|
@ -50,6 +50,6 @@ typedef struct {
|
|||
char sexpLen[MAX_NUM_BLOCK]; /*switch expression length */
|
||||
} SBlock;
|
||||
|
||||
bool simParseExpression(char *token, int lineNum);
|
||||
bool simParseExpression(char *token, int32_t lineNum);
|
||||
|
||||
#endif
|
|
@ -13,6 +13,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "os.h"
|
||||
#include "sim.h"
|
||||
#include "taos.h"
|
||||
|
@ -44,7 +45,7 @@ void simLogSql(char *sql, bool useSharp) {
|
|||
|
||||
char *simParseArbitratorName(char *varName);
|
||||
char *simParseHostName(char *varName);
|
||||
char *simGetVariable(SScript *script, char *varName, int varLen) {
|
||||
char *simGetVariable(SScript *script, char *varName, int32_t varLen) {
|
||||
if (strncmp(varName, "hostname", 8) == 0) {
|
||||
return simParseHostName(varName);
|
||||
}
|
||||
|
@ -57,11 +58,9 @@ char *simGetVariable(SScript *script, char *varName, int varLen) {
|
|||
|
||||
if (strncmp(varName, "rows", varLen) == 0) return script->rows;
|
||||
|
||||
if (strncmp(varName, "system_exit", varLen) == 0)
|
||||
return script->system_exit_code;
|
||||
if (strncmp(varName, "system_exit", varLen) == 0) return script->system_exit_code;
|
||||
|
||||
if (strncmp(varName, "system_content", varLen) == 0)
|
||||
return script->system_ret_content;
|
||||
if (strncmp(varName, "system_content", varLen) == 0) return script->system_ret_content;
|
||||
|
||||
// variable like data2_192.168.0.1
|
||||
if (strncmp(varName, "data", 4) == 0) {
|
||||
|
@ -70,16 +69,16 @@ char *simGetVariable(SScript *script, char *varName, int varLen) {
|
|||
}
|
||||
|
||||
if (varName[5] == '_') {
|
||||
int col = varName[4] - '0';
|
||||
int32_t col = varName[4] - '0';
|
||||
if (col < 0 || col >= MAX_QUERY_COL_NUM) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
char * keyName;
|
||||
int keyLen;
|
||||
int32_t keyLen;
|
||||
paGetToken(varName + 6, &keyName, &keyLen);
|
||||
|
||||
for (int i = 0; i < MAX_QUERY_ROW_NUM; ++i) {
|
||||
for (int32_t i = 0; i < MAX_QUERY_ROW_NUM; ++i) {
|
||||
if (strncmp(keyName, script->data[i][0], keyLen) == 0) {
|
||||
simDebug("script:%s, keyName:%s, keyValue:%s", script->fileName, script->data[i][0], script->data[i][col]);
|
||||
return script->data[i][col];
|
||||
|
@ -87,16 +86,16 @@ char *simGetVariable(SScript *script, char *varName, int varLen) {
|
|||
}
|
||||
return "null";
|
||||
} else if (varName[6] == '_') {
|
||||
int col = (varName[4] - '0') * 10 + (varName[5] - '0');
|
||||
int32_t col = (varName[4] - '0') * 10 + (varName[5] - '0');
|
||||
if (col < 0 || col >= MAX_QUERY_COL_NUM) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
char * keyName;
|
||||
int keyLen;
|
||||
int32_t keyLen;
|
||||
paGetToken(varName + 7, &keyName, &keyLen);
|
||||
|
||||
for (int i = 0; i < MAX_QUERY_ROW_NUM; ++i) {
|
||||
for (int32_t i = 0; i < MAX_QUERY_ROW_NUM; ++i) {
|
||||
if (strncmp(keyName, script->data[i][0], keyLen) == 0) {
|
||||
simTrace("script:%s, keyName:%s, keyValue:%s", script->fileName, script->data[i][0], script->data[i][col]);
|
||||
return script->data[i][col];
|
||||
|
@ -104,8 +103,8 @@ char *simGetVariable(SScript *script, char *varName, int varLen) {
|
|||
}
|
||||
return "null";
|
||||
} else {
|
||||
int row = varName[4] - '0';
|
||||
int col = varName[5] - '0';
|
||||
int32_t row = varName[4] - '0';
|
||||
int32_t col = varName[5] - '0';
|
||||
if (row < 0 || row >= MAX_QUERY_ROW_NUM) {
|
||||
return "null";
|
||||
}
|
||||
|
@ -118,7 +117,7 @@ char *simGetVariable(SScript *script, char *varName, int varLen) {
|
|||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < script->varLen; ++i) {
|
||||
for (int32_t i = 0; i < script->varLen; ++i) {
|
||||
SVariable *var = &script->variables[i];
|
||||
if (var->varNameLen != varLen) {
|
||||
continue;
|
||||
|
@ -144,11 +143,11 @@ char *simGetVariable(SScript *script, char *varName, int varLen) {
|
|||
return var->varValue;
|
||||
}
|
||||
|
||||
int simExecuteExpression(SScript *script, char *exp) {
|
||||
int32_t simExecuteExpression(SScript *script, char *exp) {
|
||||
char * op1, *op2, *var1, *var2, *var3, *rest;
|
||||
int op1Len, op2Len, var1Len, var2Len, var3Len, val0, val1;
|
||||
int32_t op1Len, op2Len, var1Len, var2Len, var3Len, val0, val1;
|
||||
char t0[512], t1[512], t2[512], t3[1024];
|
||||
int result;
|
||||
int32_t result;
|
||||
|
||||
rest = paGetToken(exp, &var1, &var1Len);
|
||||
rest = paGetToken(rest, &op1, &op1Len);
|
||||
|
@ -234,7 +233,7 @@ bool simExecuteExpCmd(SScript *script, char *option) {
|
|||
}
|
||||
|
||||
bool simExecuteTestCmd(SScript *script, char *option) {
|
||||
int result;
|
||||
int32_t result;
|
||||
result = simExecuteExpression(script, option);
|
||||
|
||||
if (result >= 0)
|
||||
|
@ -285,13 +284,12 @@ bool simExecuteRunBackCmd(SScript *script, char *option) {
|
|||
sprintf(script->error, "lineNum:%d. parse file:%s error", script->lines[script->linePos].lineNum, fileName);
|
||||
return false;
|
||||
}
|
||||
simInfo("script:%s, start to execute in background", newScript->fileName);
|
||||
|
||||
newScript->type = SIM_SCRIPT_TYPE_BACKGROUND;
|
||||
script->bgScripts[script->bgScriptLen++] = newScript;
|
||||
simInfo("script:%s, start to execute in background,", newScript->fileName);
|
||||
|
||||
pthread_t pid;
|
||||
if (pthread_create(&pid, NULL, simExecuteScript, (void *)newScript) != 0) {
|
||||
if (pthread_create(&newScript->bgPid, NULL, simExecuteScript, (void *)newScript) != 0) {
|
||||
sprintf(script->error, "lineNum:%d. create background thread failed", script->lines[script->linePos].lineNum);
|
||||
return false;
|
||||
}
|
||||
|
@ -307,11 +305,11 @@ bool simExecuteSystemCmd(SScript *script, char *option) {
|
|||
simVisuallizeOption(script, option, buf + strlen(buf));
|
||||
|
||||
simLogSql(buf, true);
|
||||
int code = system(buf);
|
||||
int repeatTimes = 0;
|
||||
int32_t code = system(buf);
|
||||
int32_t repeatTimes = 0;
|
||||
while (code < 0) {
|
||||
simError("script:%s, failed to execute %s , code %d, errno:%d %s, repeatTimes:%d",
|
||||
script->fileName, buf, code, errno, strerror(errno), repeatTimes);
|
||||
simError("script:%s, failed to execute %s , code %d, errno:%d %s, repeatTimes:%d", script->fileName, buf, code,
|
||||
errno, strerror(errno), repeatTimes);
|
||||
taosMsleep(1000);
|
||||
#ifdef LINUX
|
||||
signal(SIGCHLD, SIG_DFL);
|
||||
|
@ -368,7 +366,7 @@ bool simExecutePrintCmd(SScript *script, char *rest) {
|
|||
}
|
||||
|
||||
bool simExecuteSleepCmd(SScript *script, char *option) {
|
||||
int delta;
|
||||
int32_t delta;
|
||||
char buf[1024];
|
||||
|
||||
simVisuallizeOption(script, option, buf);
|
||||
|
@ -395,7 +393,7 @@ bool simExecuteReturnCmd(SScript *script, char *option) {
|
|||
simVisuallizeOption(script, option, buf);
|
||||
option = buf;
|
||||
|
||||
int ret = 1;
|
||||
int32_t ret = 1;
|
||||
if (option && option[0] != 0) ret = atoi(option);
|
||||
|
||||
if (ret < 0) {
|
||||
|
@ -412,7 +410,7 @@ bool simExecuteReturnCmd(SScript *script, char *option) {
|
|||
|
||||
void simVisuallizeOption(SScript *script, char *src, char *dst) {
|
||||
char * var, *token, *value;
|
||||
int dstLen, srcLen, tokenLen;
|
||||
int32_t dstLen, srcLen, tokenLen;
|
||||
|
||||
dst[0] = 0, dstLen = 0;
|
||||
|
||||
|
@ -420,14 +418,14 @@ void simVisuallizeOption(SScript *script, char *src, char *dst) {
|
|||
var = strchr(src, '$');
|
||||
if (var == NULL) break;
|
||||
if (var && ((var - src - 1) > 0) && *(var - 1) == '\\') {
|
||||
srcLen = (int)(var - src - 1);
|
||||
srcLen = (int32_t)(var - src - 1);
|
||||
memcpy(dst + dstLen, src, srcLen);
|
||||
dstLen += srcLen;
|
||||
src = var;
|
||||
break;
|
||||
}
|
||||
|
||||
srcLen = (int)(var - src);
|
||||
srcLen = (int32_t)(var - src);
|
||||
memcpy(dst + dstLen, src, srcLen);
|
||||
dstLen += srcLen;
|
||||
|
||||
|
@ -435,7 +433,7 @@ void simVisuallizeOption(SScript *script, char *src, char *dst) {
|
|||
value = simGetVariable(script, token, tokenLen);
|
||||
|
||||
strcpy(dst + dstLen, value);
|
||||
dstLen += (int)strlen(value);
|
||||
dstLen += (int32_t)strlen(value);
|
||||
}
|
||||
|
||||
strcpy(dst + dstLen, src);
|
||||
|
@ -465,7 +463,7 @@ void simCloseTaosdConnect(SScript *script) {
|
|||
// {"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"}
|
||||
// {"status":"succ","head":["affected_rows"],"data":[[1]],"rows":1}
|
||||
// {"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10]],"rows":10}
|
||||
int simParseHttpCommandResult(SScript *script, char *command) {
|
||||
int32_t simParseHttpCommandResult(SScript *script, char *command) {
|
||||
cJSON* root = cJSON_Parse(command);
|
||||
if (root == NULL) {
|
||||
simError("script:%s, failed to parse json, response:%s", script->fileName, command);
|
||||
|
@ -492,9 +490,10 @@ int simParseHttpCommandResult(SScript *script, char *command) {
|
|||
cJSON_Delete(root);
|
||||
return -1;
|
||||
}
|
||||
int retcode = (int)code->valueint;
|
||||
int32_t retcode = (int32_t)code->valueint;
|
||||
if (retcode != 1017) {
|
||||
simError("script:%s, json:status:%s not equal to succ, response:%s", script->fileName, status->valuestring, command);
|
||||
simError("script:%s, json:status:%s not equal to succ, response:%s", script->fileName, status->valuestring,
|
||||
command);
|
||||
cJSON_Delete(root);
|
||||
return retcode;
|
||||
} else {
|
||||
|
@ -524,27 +523,27 @@ int simParseHttpCommandResult(SScript *script, char *command) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int rowsize = cJSON_GetArraySize(data);
|
||||
int32_t rowsize = cJSON_GetArraySize(data);
|
||||
if (rowsize < 0) {
|
||||
simError("script:%s, failed to parse json:data, data size %d, response:%s", script->fileName, rowsize, command);
|
||||
cJSON_Delete(root);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int rowIndex = 0;
|
||||
int32_t rowIndex = 0;
|
||||
sprintf(script->rows, "%d", rowsize);
|
||||
for (int r = 0; r < rowsize; ++r) {
|
||||
for (int32_t r = 0; r < rowsize; ++r) {
|
||||
cJSON *row = cJSON_GetArrayItem(data, r);
|
||||
if (row == NULL) continue;
|
||||
if (rowIndex++ >= 10) break;
|
||||
|
||||
int colsize = cJSON_GetArraySize(row);
|
||||
int32_t colsize = cJSON_GetArraySize(row);
|
||||
if (colsize < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
colsize = MIN(10, colsize);
|
||||
for (int c = 0; c < colsize; ++c) {
|
||||
for (int32_t c = 0; c < colsize; ++c) {
|
||||
cJSON *col = cJSON_GetArrayItem(row, c);
|
||||
if (col->valuestring != NULL) {
|
||||
strcpy(script->data[r][c], col->valuestring);
|
||||
|
@ -561,7 +560,7 @@ int simParseHttpCommandResult(SScript *script, char *command) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int simExecuteRestFulCommand(SScript *script, char *command) {
|
||||
int32_t simExecuteRestFulCommand(SScript *script, char *command) {
|
||||
char buf[5000] = {0};
|
||||
sprintf(buf, "%s 2>/dev/null", command);
|
||||
|
||||
|
@ -571,13 +570,13 @@ int simExecuteRestFulCommand(SScript *script, char *command) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int mallocSize = 2000;
|
||||
int alreadyReadSize = 0;
|
||||
int32_t mallocSize = 2000;
|
||||
int32_t alreadyReadSize = 0;
|
||||
char * content = malloc(mallocSize);
|
||||
|
||||
while (!feof(fp)) {
|
||||
int availSize = mallocSize - alreadyReadSize;
|
||||
int len = (int)fread(content + alreadyReadSize, 1, availSize, fp);
|
||||
int32_t availSize = mallocSize - alreadyReadSize;
|
||||
int32_t len = (int32_t)fread(content + alreadyReadSize, 1, availSize, fp);
|
||||
if (len >= availSize) {
|
||||
alreadyReadSize += len;
|
||||
mallocSize *= 2;
|
||||
|
@ -595,10 +594,11 @@ bool simCreateRestFulConnect(SScript *script, char *user, char *pass) {
|
|||
sprintf(command, "curl 127.0.0.1:6041/rest/login/%s/%s", user, pass);
|
||||
|
||||
bool success = false;
|
||||
for (int attempt = 0; attempt < 10; ++attempt) {
|
||||
for (int32_t attempt = 0; attempt < 10; ++attempt) {
|
||||
success = simExecuteRestFulCommand(script, command) == 0;
|
||||
if (!success) {
|
||||
simDebug("script:%s, user:%s connect taosd failed:%s, attempt:%d", script->fileName, user, taos_errstr(NULL), attempt);
|
||||
simDebug("script:%s, user:%s connect taosd failed:%s, attempt:%d", script->fileName, user, taos_errstr(NULL),
|
||||
attempt);
|
||||
taosMsleep(1000);
|
||||
} else {
|
||||
simDebug("script:%s, user:%s connect taosd successed, attempt:%d", script->fileName, user, attempt);
|
||||
|
@ -607,7 +607,8 @@ bool simCreateRestFulConnect(SScript *script, char *user, char *pass) {
|
|||
}
|
||||
|
||||
if (!success) {
|
||||
sprintf(script->error, "lineNum:%d. connect taosd failed:%s", script->lines[script->linePos].lineNum, taos_errstr(NULL));
|
||||
sprintf(script->error, "lineNum:%d. connect taosd failed:%s", script->lines[script->linePos].lineNum,
|
||||
taos_errstr(NULL));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -619,10 +620,11 @@ bool simCreateNativeConnect(SScript *script, char *user, char *pass) {
|
|||
simCloseTaosdConnect(script);
|
||||
void *taos = NULL;
|
||||
taosMsleep(2000);
|
||||
for (int attempt = 0; attempt < 10; ++attempt) {
|
||||
for (int32_t attempt = 0; attempt < 10; ++attempt) {
|
||||
taos = taos_connect(NULL, user, pass, NULL, tsDnodeShellPort);
|
||||
if (taos == NULL) {
|
||||
simDebug("script:%s, user:%s connect taosd failed:%s, attempt:%d", script->fileName, user, taos_errstr(NULL), attempt);
|
||||
simDebug("script:%s, user:%s connect taosd failed:%s, attempt:%d", script->fileName, user, taos_errstr(NULL),
|
||||
attempt);
|
||||
taosMsleep(1000);
|
||||
} else {
|
||||
simDebug("script:%s, user:%s connect taosd successed, attempt:%d", script->fileName, user, attempt);
|
||||
|
@ -631,7 +633,8 @@ bool simCreateNativeConnect(SScript *script, char *user, char *pass) {
|
|||
}
|
||||
|
||||
if (taos == NULL) {
|
||||
sprintf(script->error, "lineNum:%d. connect taosd failed:%s", script->lines[script->linePos].lineNum, taos_errstr(NULL));
|
||||
sprintf(script->error, "lineNum:%d. connect taosd failed:%s", script->lines[script->linePos].lineNum,
|
||||
taos_errstr(NULL));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -644,7 +647,7 @@ bool simCreateNativeConnect(SScript *script, char *user, char *pass) {
|
|||
bool simCreateTaosdConnect(SScript *script, char *rest) {
|
||||
char * user = TSDB_DEFAULT_USER;
|
||||
char * token;
|
||||
int tokenLen;
|
||||
int32_t tokenLen;
|
||||
rest = paGetToken(rest, &token, &tokenLen);
|
||||
rest = paGetToken(rest, &token, &tokenLen);
|
||||
if (tokenLen != 0) {
|
||||
|
@ -663,22 +666,23 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
|
|||
time_t tt;
|
||||
struct tm *tp;
|
||||
SCmdLine * line = &script->lines[script->linePos];
|
||||
int ret = -1;
|
||||
int32_t ret = -1;
|
||||
|
||||
TAOS_RES *pSql = NULL;
|
||||
|
||||
for (int attempt = 0; attempt < 10; ++attempt) {
|
||||
for (int32_t attempt = 0; attempt < 10; ++attempt) {
|
||||
simLogSql(rest, false);
|
||||
pSql = taos_query(script->taos, rest);
|
||||
ret = taos_errno(pSql);
|
||||
|
||||
if (ret == TSDB_CODE_MND_TABLE_ALREADY_EXIST || ret == TSDB_CODE_MND_DB_ALREADY_EXIST) {
|
||||
simDebug("script:%s, taos:%p, %s success, ret:%d:%s", script->fileName, script->taos, rest, ret & 0XFFFF, tstrerror(ret));
|
||||
simDebug("script:%s, taos:%p, %s success, ret:%d:%s", script->fileName, script->taos, rest, ret & 0XFFFF,
|
||||
tstrerror(ret));
|
||||
ret = 0;
|
||||
break;
|
||||
} else if (ret != 0) {
|
||||
simDebug("script:%s, taos:%p, %s failed, ret:%d:%s, error:%s",
|
||||
script->fileName, script->taos, rest, ret & 0XFFFF, tstrerror(ret), taos_errstr(pSql));
|
||||
simDebug("script:%s, taos:%p, %s failed, ret:%d:%s, error:%s", script->fileName, script->taos, rest, ret & 0XFFFF,
|
||||
tstrerror(ret), taos_errstr(pSql));
|
||||
|
||||
if (line->errorJump == SQL_JUMP_TRUE) {
|
||||
script->linePos = line->jump;
|
||||
|
@ -698,8 +702,8 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
|
|||
return false;
|
||||
}
|
||||
|
||||
int numOfRows = 0;
|
||||
int num_fields = taos_field_count(pSql);
|
||||
int32_t numOfRows = 0;
|
||||
int32_t num_fields = taos_field_count(pSql);
|
||||
if (num_fields != 0) {
|
||||
if (pSql == NULL) {
|
||||
simDebug("script:%s, taos:%p, %s failed, result is null", script->fileName, script->taos, rest);
|
||||
|
@ -717,9 +721,9 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
|
|||
while ((row = taos_fetch_row(pSql))) {
|
||||
if (numOfRows < MAX_QUERY_ROW_NUM) {
|
||||
TAOS_FIELD *fields = taos_fetch_fields(pSql);
|
||||
int* length = taos_fetch_lengths(pSql);
|
||||
int32_t * length = taos_fetch_lengths(pSql);
|
||||
|
||||
for (int i = 0; i < num_fields; i++) {
|
||||
for (int32_t i = 0; i < num_fields; i++) {
|
||||
char *value = NULL;
|
||||
if (i < MAX_QUERY_COL_NUM) {
|
||||
value = script->data[numOfRows][i];
|
||||
|
@ -735,8 +739,7 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
|
|||
|
||||
switch (fields[i].type) {
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
sprintf(value, "%s",
|
||||
((((int)(*((char *)row[i]))) == 1) ? "1" : "0"));
|
||||
sprintf(value, "%s", ((((int32_t)(*((char *)row[i]))) == 1) ? "1" : "0"));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
sprintf(value, "%d", *((int8_t *)row[i]));
|
||||
|
@ -779,8 +782,7 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
|
|||
|
||||
tp = localtime(&tt);
|
||||
strftime(timeStr, 64, "%y-%m-%d %H:%M:%S", tp);
|
||||
sprintf(value, "%s.%03d", timeStr,
|
||||
(int)(*((int64_t *)row[i]) % 1000));
|
||||
sprintf(value, "%s.%03d", timeStr, (int32_t)(*((int64_t *)row[i]) % 1000));
|
||||
|
||||
break;
|
||||
default:
|
||||
|
@ -814,17 +816,16 @@ bool simExecuteRestFulSqlCommand(SScript *script, char *rest) {
|
|||
char command[4096];
|
||||
sprintf(command, "curl -H 'Authorization: Taosd %s' -d \"%s\" 127.0.0.1:6041/rest/sql", script->auth, rest);
|
||||
|
||||
int ret = -1;
|
||||
for (int attempt = 0; attempt < 10; ++attempt) {
|
||||
int32_t ret = -1;
|
||||
for (int32_t attempt = 0; attempt < 10; ++attempt) {
|
||||
ret = simExecuteRestFulCommand(script, command);
|
||||
if (ret == TSDB_CODE_MND_TABLE_ALREADY_EXIST ||
|
||||
ret == TSDB_CODE_MND_DB_ALREADY_EXIST) {
|
||||
simDebug("script:%s, taos:%p, %s success, ret:%d:%s", script->fileName, script->taos, rest, ret & 0XFFFF, tstrerror(ret));
|
||||
if (ret == TSDB_CODE_MND_TABLE_ALREADY_EXIST || ret == TSDB_CODE_MND_DB_ALREADY_EXIST) {
|
||||
simDebug("script:%s, taos:%p, %s success, ret:%d:%s", script->fileName, script->taos, rest, ret & 0XFFFF,
|
||||
tstrerror(ret));
|
||||
ret = 0;
|
||||
break;
|
||||
} else if (ret != 0) {
|
||||
simDebug("script:%s, taos:%p, %s failed, ret:%d",
|
||||
script->fileName, script->taos, rest, ret);
|
||||
simDebug("script:%s, taos:%p, %s failed, ret:%d", script->fileName, script->taos, rest, ret);
|
||||
|
||||
if (line->errorJump == SQL_JUMP_TRUE) {
|
||||
script->linePos = line->jump;
|
||||
|
@ -854,8 +855,8 @@ bool simExecuteSqlImpCmd(SScript *script, char *rest, bool isSlow) {
|
|||
|
||||
simDebug("script:%s, exec:%s", script->fileName, rest);
|
||||
strcpy(script->rows, "-1");
|
||||
for (int row = 0; row < MAX_QUERY_ROW_NUM; ++row) {
|
||||
for (int col = 0; col < MAX_QUERY_COL_NUM; ++col) {
|
||||
for (int32_t row = 0; row < MAX_QUERY_ROW_NUM; ++row) {
|
||||
for (int32_t col = 0; col < MAX_QUERY_COL_NUM; ++col) {
|
||||
strcpy(script->data[row][col], "null");
|
||||
}
|
||||
}
|
||||
|
@ -919,7 +920,7 @@ bool simExecuteRestfulCmd(SScript *script, char *rest) {
|
|||
sscanf(rest, "%s %s %d %d %s", db, tb, &ts, ×, gzip);
|
||||
|
||||
fprintf(fp, "insert into %s.%s values ", db, tb);
|
||||
for (int i = 0; i < times; ++i) {
|
||||
for (int32_t i = 0; i < times; ++i) {
|
||||
fprintf(fp, "(%d000, %d)", ts + i, ts);
|
||||
}
|
||||
fprintf(fp, " \n");
|
||||
|
@ -951,8 +952,8 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
|
|||
|
||||
simDebug("script:%s, exec:%s", script->fileName, rest);
|
||||
strcpy(script->rows, "-1");
|
||||
for (int row = 0; row < MAX_QUERY_ROW_NUM; ++row) {
|
||||
for (int col = 0; col < MAX_QUERY_COL_NUM; ++col) {
|
||||
for (int32_t row = 0; row < MAX_QUERY_ROW_NUM; ++row) {
|
||||
for (int32_t col = 0; col < MAX_QUERY_COL_NUM; ++col) {
|
||||
strcpy(script->data[row][col], "null");
|
||||
}
|
||||
}
|
||||
|
@ -981,27 +982,27 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
|
|||
return true;
|
||||
}
|
||||
|
||||
int ret;
|
||||
int32_t ret;
|
||||
TAOS_RES *pSql = NULL;
|
||||
if (simAsyncQuery) {
|
||||
char command[4096];
|
||||
sprintf(command, "curl -H 'Authorization: Taosd %s' -d '%s' 127.0.0.1:6041/rest/sql", script->auth, rest);
|
||||
ret = simExecuteRestFulCommand(script, command);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
pSql = taos_query(script->taos, rest);
|
||||
ret = taos_errno(pSql);
|
||||
taos_free_result(pSql);
|
||||
}
|
||||
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
simDebug("script:%s, taos:%p, %s execute, expect failed, so success, ret:%d:%s",
|
||||
script->fileName, script->taos, rest, ret & 0XFFFF, tstrerror(ret));
|
||||
simDebug("script:%s, taos:%p, %s execute, expect failed, so success, ret:%d:%s", script->fileName, script->taos,
|
||||
rest, ret & 0XFFFF, tstrerror(ret));
|
||||
script->linePos++;
|
||||
return true;
|
||||
}
|
||||
|
||||
sprintf(script->error, "lineNum:%d. sql:%s expect failed, but success, ret:%d:%s", line->lineNum, rest, ret & 0XFFFF, tstrerror(ret));
|
||||
sprintf(script->error, "lineNum:%d. sql:%s expect failed, but success, ret:%d:%s", line->lineNum, rest, ret & 0XFFFF,
|
||||
tstrerror(ret));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "os.h"
|
||||
#include "tglobal.h"
|
||||
#include "sim.h"
|
||||
|
@ -20,15 +21,15 @@
|
|||
|
||||
bool simAsyncQuery = false;
|
||||
|
||||
void simHandleSignal(int signo) {
|
||||
void simHandleSignal(int32_t signo) {
|
||||
simSystemCleanUp();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int32_t main(int32_t argc, char *argv[]) {
|
||||
char scriptFile[MAX_FILE_NAME_LEN] = "sim_main_test.sim";
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
for (int32_t i = 1; i < argc; ++i) {
|
||||
if (strcmp(argv[i], "-c") == 0 && i < argc - 1) {
|
||||
tstrncpy(configDir, argv[++i], MAX_FILE_NAME_LEN);
|
||||
} else if (strcmp(argv[i], "-f") == 0 && i < argc - 1) {
|
||||
|
@ -37,8 +38,7 @@ int main(int argc, char *argv[]) {
|
|||
simAsyncQuery = true;
|
||||
} else {
|
||||
printf("usage: %s [options] \n", argv[0]);
|
||||
printf(" [-c config]: config directory, default is: %s\n",
|
||||
configDir);
|
||||
printf(" [-c config]: config directory, default is: %s\n", configDir);
|
||||
printf(" [-f script]: script filename\n");
|
||||
exit(0);
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "os.h"
|
||||
#include "sim.h"
|
||||
#include "simParse.h"
|
||||
|
@ -67,13 +68,13 @@ static SCommand *cmdHashList[MAX_NUM_CMD];
|
|||
static SCmdLine cmdLine[MAX_CMD_LINES];
|
||||
static char parseErr[MAX_ERROR_LEN];
|
||||
static char optionBuffer[MAX_OPTION_BUFFER];
|
||||
static int numOfLines, optionOffset;
|
||||
static int32_t numOfLines, optionOffset;
|
||||
static SLabel label, dest;
|
||||
static SBlock block;
|
||||
|
||||
int simHashCmd(char *token, int tokenLen) {
|
||||
int i;
|
||||
int hash = 0;
|
||||
int32_t simHashCmd(char *token, int32_t tokenLen) {
|
||||
int32_t i;
|
||||
int32_t hash = 0;
|
||||
|
||||
for (i = 0; i < tokenLen; ++i) hash += token[i];
|
||||
|
||||
|
@ -82,8 +83,8 @@ int simHashCmd(char *token, int tokenLen) {
|
|||
return hash;
|
||||
}
|
||||
|
||||
SCommand *simCheckCmd(char *token, int tokenLen) {
|
||||
int hash;
|
||||
SCommand *simCheckCmd(char *token, int32_t tokenLen) {
|
||||
int32_t hash;
|
||||
SCommand *node;
|
||||
|
||||
hash = simHashCmd(token, tokenLen);
|
||||
|
@ -102,10 +103,10 @@ SCommand *simCheckCmd(char *token, int tokenLen) {
|
|||
}
|
||||
|
||||
void simAddCmdIntoHash(SCommand *pCmd) {
|
||||
int hash;
|
||||
int32_t hash;
|
||||
SCommand *node;
|
||||
|
||||
hash = simHashCmd(pCmd->name, (int)strlen(pCmd->name));
|
||||
hash = simHashCmd(pCmd->name, (int32_t)strlen(pCmd->name));
|
||||
node = cmdHashList[hash];
|
||||
pCmd->next = node;
|
||||
cmdHashList[hash] = pCmd;
|
||||
|
@ -122,7 +123,7 @@ void simResetParser() {
|
|||
}
|
||||
|
||||
SScript *simBuildScriptObj(char *fileName) {
|
||||
int i, destPos;
|
||||
int32_t i, destPos;
|
||||
|
||||
/* process labels */
|
||||
|
||||
|
@ -177,7 +178,7 @@ SScript *simBuildScriptObj(char *fileName) {
|
|||
|
||||
SScript *simParseScript(char *fileName) {
|
||||
FILE * fd;
|
||||
int tokenLen, lineNum = 0;
|
||||
int32_t tokenLen, lineNum = 0;
|
||||
char buffer[MAX_LINE_LEN], name[128], *token, *rest;
|
||||
SCommand *pCmd;
|
||||
SScript * script;
|
||||
|
@ -199,12 +200,13 @@ SScript *simParseScript(char *fileName) {
|
|||
if (fgets(buffer, sizeof(buffer), fd) == NULL) continue;
|
||||
|
||||
lineNum++;
|
||||
int cmdlen = (int)strlen(buffer);
|
||||
if (buffer[cmdlen - 1] == '\r' || buffer[cmdlen - 1] == '\n')
|
||||
int32_t cmdlen = (int32_t)strlen(buffer);
|
||||
if (buffer[cmdlen - 1] == '\r' || buffer[cmdlen - 1] == '\n') {
|
||||
buffer[cmdlen - 1] = 0;
|
||||
}
|
||||
rest = buffer;
|
||||
|
||||
for (int i = 0; i < cmdlen; ++i) {
|
||||
for (int32_t i = 0; i < cmdlen; ++i) {
|
||||
if (buffer[i] == '\r' || buffer[i] == '\n') {
|
||||
buffer[i] = ' ';
|
||||
}
|
||||
|
@ -249,9 +251,9 @@ SScript *simParseScript(char *fileName) {
|
|||
return script;
|
||||
}
|
||||
|
||||
int simCheckExpression(char *exp) {
|
||||
int32_t simCheckExpression(char *exp) {
|
||||
char * op1, *op2, *op, *rest;
|
||||
int op1Len, op2Len, opLen;
|
||||
int32_t op1Len, op2Len, opLen;
|
||||
|
||||
rest = paGetToken(exp, &op1, &op1Len);
|
||||
if (op1Len == 0) {
|
||||
|
@ -282,8 +284,7 @@ int simCheckExpression(char *exp) {
|
|||
return -1;
|
||||
}
|
||||
} else if (opLen == 2) {
|
||||
if (op[1] != '=' ||
|
||||
(op[0] != '=' && op[0] != '<' && op[0] != '>' && op[0] != '!')) {
|
||||
if (op[1] != '=' || (op[0] != '=' && op[0] != '<' && op[0] != '>' && op[0] != '!')) {
|
||||
sprintf(parseErr, "left side of assignment must be variable");
|
||||
return -1;
|
||||
}
|
||||
|
@ -294,10 +295,10 @@ int simCheckExpression(char *exp) {
|
|||
|
||||
rest = paGetToken(rest, &op, &opLen);
|
||||
|
||||
if (opLen == 0) return (int)(rest - exp);
|
||||
if (opLen == 0) return (int32_t)(rest - exp);
|
||||
|
||||
/* if it is key word "then" */
|
||||
if (strncmp(op, "then", 4) == 0) return (int)(op - exp);
|
||||
if (strncmp(op, "then", 4) == 0) return (int32_t)(op - exp);
|
||||
|
||||
rest = paGetToken(rest, &op2, &op2Len);
|
||||
if (op2Len == 0) {
|
||||
|
@ -310,16 +311,15 @@ int simCheckExpression(char *exp) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (op[0] == '+' || op[0] == '-' || op[0] == '*' || op[0] == '/' ||
|
||||
op[0] == '.') {
|
||||
return (int)(rest - exp);
|
||||
if (op[0] == '+' || op[0] == '-' || op[0] == '*' || op[0] == '/' || op[0] == '.') {
|
||||
return (int32_t)(rest - exp);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool simParseExpression(char *token, int lineNum) {
|
||||
int expLen;
|
||||
bool simParseExpression(char *token, int32_t lineNum) {
|
||||
int32_t expLen;
|
||||
|
||||
expLen = simCheckExpression(token);
|
||||
if (expLen <= 0) return -1;
|
||||
|
@ -335,9 +335,9 @@ bool simParseExpression(char *token, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseIfCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
bool simParseIfCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
char * ret;
|
||||
int expLen;
|
||||
int32_t expLen;
|
||||
|
||||
expLen = simCheckExpression(rest);
|
||||
|
||||
|
@ -364,8 +364,8 @@ bool simParseIfCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseElifCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
int expLen;
|
||||
bool simParseElifCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
int32_t expLen;
|
||||
|
||||
expLen = simCheckExpression(rest);
|
||||
|
||||
|
@ -382,8 +382,7 @@ bool simParseElifCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
}
|
||||
|
||||
cmdLine[numOfLines].cmdno = SIM_CMD_GOTO;
|
||||
block.jump[block.top - 1][(uint8_t)block.numJump[block.top - 1]] =
|
||||
&(cmdLine[numOfLines].jump);
|
||||
block.jump[block.top - 1][(uint8_t)block.numJump[block.top - 1]] = &(cmdLine[numOfLines].jump);
|
||||
block.numJump[block.top - 1]++;
|
||||
|
||||
numOfLines++;
|
||||
|
@ -402,7 +401,7 @@ bool simParseElifCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseElseCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
bool simParseElseCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
if (block.top < 1) {
|
||||
sprintf(parseErr, "no matching if");
|
||||
return false;
|
||||
|
@ -414,8 +413,7 @@ bool simParseElseCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
}
|
||||
|
||||
cmdLine[numOfLines].cmdno = SIM_CMD_GOTO;
|
||||
block.jump[block.top - 1][(uint8_t)block.numJump[block.top - 1]] =
|
||||
&(cmdLine[numOfLines].jump);
|
||||
block.jump[block.top - 1][(uint8_t)block.numJump[block.top - 1]] = &(cmdLine[numOfLines].jump);
|
||||
block.numJump[block.top - 1]++;
|
||||
|
||||
numOfLines++;
|
||||
|
@ -426,8 +424,8 @@ bool simParseElseCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseEndiCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
int i;
|
||||
bool simParseEndiCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
int32_t i;
|
||||
|
||||
if (block.top < 1) {
|
||||
sprintf(parseErr, "no matching if");
|
||||
|
@ -441,8 +439,9 @@ bool simParseEndiCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
|
||||
if (block.pos[block.top - 1]) *(block.pos[block.top - 1]) = numOfLines;
|
||||
|
||||
for (i = 0; i < block.numJump[block.top - 1]; ++i)
|
||||
for (i = 0; i < block.numJump[block.top - 1]; ++i) {
|
||||
*(block.jump[block.top - 1][i]) = numOfLines;
|
||||
}
|
||||
|
||||
block.numJump[block.top - 1] = 0;
|
||||
block.top--;
|
||||
|
@ -450,8 +449,8 @@ bool simParseEndiCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseWhileCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
int expLen;
|
||||
bool simParseWhileCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
int32_t expLen;
|
||||
|
||||
expLen = simCheckExpression(rest);
|
||||
|
||||
|
@ -473,8 +472,8 @@ bool simParseWhileCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseEndwCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
int i;
|
||||
bool simParseEndwCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
int32_t i;
|
||||
|
||||
if (block.top < 1) {
|
||||
sprintf(parseErr, "no matching while");
|
||||
|
@ -493,17 +492,18 @@ bool simParseEndwCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
|
||||
*(block.pos[block.top - 1]) = numOfLines;
|
||||
|
||||
for (i = 0; i < block.numJump[block.top - 1]; ++i)
|
||||
for (i = 0; i < block.numJump[block.top - 1]; ++i) {
|
||||
*(block.jump[block.top - 1][i]) = numOfLines;
|
||||
}
|
||||
|
||||
block.top--;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool simParseSwitchCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
bool simParseSwitchCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
char * token;
|
||||
int tokenLen;
|
||||
int32_t tokenLen;
|
||||
|
||||
rest = paGetToken(rest, &token, &tokenLen);
|
||||
if (tokenLen == 0) {
|
||||
|
@ -524,9 +524,9 @@ bool simParseSwitchCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseCaseCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
bool simParseCaseCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
char * token;
|
||||
int tokenLen;
|
||||
int32_t tokenLen;
|
||||
|
||||
rest = paGetToken(rest, &token, &tokenLen);
|
||||
if (tokenLen == 0) {
|
||||
|
@ -544,16 +544,16 @@ bool simParseCaseCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (block.pos[block.top - 1] != NULL)
|
||||
if (block.pos[block.top - 1] != NULL) {
|
||||
*(block.pos[block.top - 1]) = numOfLines;
|
||||
}
|
||||
|
||||
block.pos[block.top - 1] = &(cmdLine[numOfLines].jump);
|
||||
|
||||
cmdLine[numOfLines].cmdno = SIM_CMD_TEST;
|
||||
cmdLine[numOfLines].lineNum = lineNum;
|
||||
cmdLine[numOfLines].optionOffset = optionOffset;
|
||||
memcpy(optionBuffer + optionOffset, block.sexp[block.top - 1],
|
||||
block.sexpLen[block.top - 1]);
|
||||
memcpy(optionBuffer + optionOffset, block.sexp[block.top - 1], block.sexpLen[block.top - 1]);
|
||||
optionOffset += block.sexpLen[block.top - 1];
|
||||
*(optionBuffer + optionOffset++) = ' ';
|
||||
*(optionBuffer + optionOffset++) = '=';
|
||||
|
@ -567,20 +567,18 @@ bool simParseCaseCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseBreakCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
bool simParseBreakCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
if (block.top < 1) {
|
||||
sprintf(parseErr, "no blcok exists");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (block.type[block.top - 1] != BLOCK_SWITCH &&
|
||||
block.type[block.top - 1] != BLOCK_WHILE) {
|
||||
if (block.type[block.top - 1] != BLOCK_SWITCH && block.type[block.top - 1] != BLOCK_WHILE) {
|
||||
sprintf(parseErr, "not in switch or while block");
|
||||
return false;
|
||||
}
|
||||
|
||||
block.jump[block.top - 1][(uint8_t)block.numJump[block.top - 1]] =
|
||||
&(cmdLine[numOfLines].jump);
|
||||
block.jump[block.top - 1][(uint8_t)block.numJump[block.top - 1]] = &(cmdLine[numOfLines].jump);
|
||||
block.numJump[block.top - 1]++;
|
||||
|
||||
cmdLine[numOfLines].cmdno = SIM_CMD_GOTO;
|
||||
|
@ -590,7 +588,7 @@ bool simParseBreakCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseDefaultCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
bool simParseDefaultCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
if (block.top < 1) {
|
||||
sprintf(parseErr, "no matching switch");
|
||||
return false;
|
||||
|
@ -601,14 +599,15 @@ bool simParseDefaultCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (block.pos[block.top - 1] != NULL)
|
||||
if (block.pos[block.top - 1] != NULL) {
|
||||
*(block.pos[block.top - 1]) = numOfLines;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool simParseEndsCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
int i;
|
||||
bool simParseEndsCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
int32_t i;
|
||||
|
||||
if (block.top < 1) {
|
||||
sprintf(parseErr, "no matching switch");
|
||||
|
@ -620,8 +619,9 @@ bool simParseEndsCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < block.numJump[block.top - 1]; ++i)
|
||||
for (i = 0; i < block.numJump[block.top - 1]; ++i) {
|
||||
*(block.jump[block.top - 1][i]) = numOfLines;
|
||||
}
|
||||
|
||||
block.numJump[block.top - 1] = 0;
|
||||
block.top--;
|
||||
|
@ -629,7 +629,7 @@ bool simParseEndsCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseContinueCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
bool simParseContinueCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
if (block.top < 1) {
|
||||
sprintf(parseErr, "no matching while");
|
||||
return false;
|
||||
|
@ -648,14 +648,14 @@ bool simParseContinueCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParsePrintCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
int expLen;
|
||||
bool simParsePrintCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
int32_t expLen;
|
||||
|
||||
rest++;
|
||||
cmdLine[numOfLines].cmdno = SIM_CMD_PRINT;
|
||||
cmdLine[numOfLines].lineNum = lineNum;
|
||||
cmdLine[numOfLines].optionOffset = optionOffset;
|
||||
expLen = (int)strlen(rest);
|
||||
expLen = (int32_t)strlen(rest);
|
||||
memcpy(optionBuffer + optionOffset, rest, expLen);
|
||||
optionOffset += expLen + 1;
|
||||
*(optionBuffer + optionOffset - 1) = 0;
|
||||
|
@ -665,7 +665,7 @@ bool simParsePrintCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
}
|
||||
|
||||
void simCheckSqlOption(char *rest) {
|
||||
int valueLen;
|
||||
int32_t valueLen;
|
||||
char * value, *xpos;
|
||||
|
||||
xpos = strstr(rest, " -x"); // need a blank
|
||||
|
@ -682,15 +682,15 @@ void simCheckSqlOption(char *rest) {
|
|||
}
|
||||
}
|
||||
|
||||
bool simParseSqlCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
int expLen;
|
||||
bool simParseSqlCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
int32_t expLen;
|
||||
|
||||
rest++;
|
||||
simCheckSqlOption(rest);
|
||||
cmdLine[numOfLines].cmdno = SIM_CMD_SQL;
|
||||
cmdLine[numOfLines].lineNum = lineNum;
|
||||
cmdLine[numOfLines].optionOffset = optionOffset;
|
||||
expLen = (int)strlen(rest);
|
||||
expLen = (int32_t)strlen(rest);
|
||||
memcpy(optionBuffer + optionOffset, rest, expLen);
|
||||
optionOffset += expLen + 1;
|
||||
*(optionBuffer + optionOffset - 1) = 0;
|
||||
|
@ -699,14 +699,14 @@ bool simParseSqlCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseSqlErrorCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
int expLen;
|
||||
bool simParseSqlErrorCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
int32_t expLen;
|
||||
|
||||
rest++;
|
||||
cmdLine[numOfLines].cmdno = SIM_CMD_SQL_ERROR;
|
||||
cmdLine[numOfLines].lineNum = lineNum;
|
||||
cmdLine[numOfLines].optionOffset = optionOffset;
|
||||
expLen = (int)strlen(rest);
|
||||
expLen = (int32_t)strlen(rest);
|
||||
memcpy(optionBuffer + optionOffset, rest, expLen);
|
||||
optionOffset += expLen + 1;
|
||||
*(optionBuffer + optionOffset - 1) = 0;
|
||||
|
@ -715,26 +715,26 @@ bool simParseSqlErrorCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseSqlSlowCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
bool simParseSqlSlowCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
simParseSqlCmd(rest, pCmd, lineNum);
|
||||
cmdLine[numOfLines - 1].cmdno = SIM_CMD_SQL_SLOW;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool simParseRestfulCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
bool simParseRestfulCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
simParseSqlCmd(rest, pCmd, lineNum);
|
||||
cmdLine[numOfLines - 1].cmdno = SIM_CMD_RESTFUL;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool simParseSystemCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
int expLen;
|
||||
bool simParseSystemCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
int32_t expLen;
|
||||
|
||||
rest++;
|
||||
cmdLine[numOfLines].cmdno = SIM_CMD_SYSTEM;
|
||||
cmdLine[numOfLines].lineNum = lineNum;
|
||||
cmdLine[numOfLines].optionOffset = optionOffset;
|
||||
expLen = (int)strlen(rest);
|
||||
expLen = (int32_t)strlen(rest);
|
||||
memcpy(optionBuffer + optionOffset, rest, expLen);
|
||||
optionOffset += expLen + 1;
|
||||
*(optionBuffer + optionOffset - 1) = 0;
|
||||
|
@ -743,15 +743,15 @@ bool simParseSystemCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseSystemContentCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
bool simParseSystemContentCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
simParseSystemCmd(rest, pCmd, lineNum);
|
||||
cmdLine[numOfLines - 1].cmdno = SIM_CMD_SYSTEM_CONTENT;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool simParseSleepCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
bool simParseSleepCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
char * token;
|
||||
int tokenLen;
|
||||
int32_t tokenLen;
|
||||
|
||||
cmdLine[numOfLines].cmdno = SIM_CMD_SLEEP;
|
||||
cmdLine[numOfLines].lineNum = lineNum;
|
||||
|
@ -768,9 +768,9 @@ bool simParseSleepCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseReturnCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
bool simParseReturnCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
char * token;
|
||||
int tokenLen;
|
||||
int32_t tokenLen;
|
||||
|
||||
cmdLine[numOfLines].cmdno = SIM_CMD_RETURN;
|
||||
cmdLine[numOfLines].lineNum = lineNum;
|
||||
|
@ -787,9 +787,9 @@ bool simParseReturnCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseGotoCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
bool simParseGotoCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
char * token;
|
||||
int tokenLen;
|
||||
int32_t tokenLen;
|
||||
|
||||
rest = paGetToken(rest, &token, &tokenLen);
|
||||
|
||||
|
@ -810,9 +810,9 @@ bool simParseGotoCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseRunCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
bool simParseRunCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
char * token;
|
||||
int tokenLen;
|
||||
int32_t tokenLen;
|
||||
|
||||
rest = paGetToken(rest, &token, &tokenLen);
|
||||
|
||||
|
@ -832,14 +832,14 @@ bool simParseRunCmd(char *rest, SCommand *pCmd, int lineNum) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simParseRunBackCmd(char *rest, SCommand *pCmd, int lineNum) {
|
||||
bool simParseRunBackCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
|
||||
simParseRunCmd(rest, pCmd, lineNum);
|
||||
cmdLine[numOfLines - 1].cmdno = SIM_CMD_RUN_BACK;
|
||||
return true;
|
||||
}
|
||||
|
||||
void simInitsimCmdList() {
|
||||
int cmdno;
|
||||
int32_t cmdno;
|
||||
memset(simCmdList, 0, SIM_CMD_END * sizeof(SCommand));
|
||||
|
||||
/* internal command */
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "os.h"
|
||||
#include "sim.h"
|
||||
#include "taos.h"
|
||||
|
@ -24,9 +25,9 @@
|
|||
|
||||
SScript *simScriptList[MAX_MAIN_SCRIPT_NUM];
|
||||
SCommand simCmdList[SIM_CMD_END];
|
||||
int simScriptPos = -1;
|
||||
int simScriptSucced = 0;
|
||||
int simDebugFlag = 135;
|
||||
int32_t simScriptPos = -1;
|
||||
int32_t simScriptSucced = 0;
|
||||
int32_t simDebugFlag = 135;
|
||||
void simCloseTaosdConnect(SScript *script);
|
||||
char simHostName[128];
|
||||
|
||||
|
@ -39,8 +40,8 @@ char *simParseArbitratorName(char *varName) {
|
|||
char *simParseHostName(char *varName) {
|
||||
static char hostName[140];
|
||||
|
||||
int index = atoi(varName + 8);
|
||||
int port = 7100;
|
||||
int32_t index = atoi(varName + 8);
|
||||
int32_t port = 7100;
|
||||
switch (index) {
|
||||
case 1:
|
||||
port = 7100;
|
||||
|
@ -88,39 +89,45 @@ void simSystemCleanUp() {}
|
|||
|
||||
void simFreeScript(SScript *script) {
|
||||
if (script->type == SIM_SCRIPT_TYPE_MAIN) {
|
||||
for (int i = 0; i < script->bgScriptLen; ++i) {
|
||||
simInfo("script:%s, background script num:%d, stop them", script->fileName, script->bgScriptLen);
|
||||
|
||||
for (int32_t i = 0; i < script->bgScriptLen; ++i) {
|
||||
SScript *bgScript = script->bgScripts[i];
|
||||
simInfo("script:%s, set stop flag", script->fileName);
|
||||
bgScript->killed = true;
|
||||
if (taosCheckPthreadValid(bgScript->bgPid)) {
|
||||
pthread_join(bgScript->bgPid, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
simDebug("script:%s, is freed", script->fileName);
|
||||
taos_close(script->taos);
|
||||
taosTFree(script->lines);
|
||||
taosTFree(script->optionBuffer);
|
||||
taosTFree(script);
|
||||
tfree(script->lines);
|
||||
tfree(script->optionBuffer);
|
||||
tfree(script);
|
||||
}
|
||||
|
||||
SScript *simProcessCallOver(SScript *script) {
|
||||
if (script->type == SIM_SCRIPT_TYPE_MAIN) {
|
||||
if (script->killed) {
|
||||
simInfo("script:" FAILED_PREFIX "%s" FAILED_POSTFIX ", " FAILED_PREFIX
|
||||
"failed" FAILED_POSTFIX ", error:%s",
|
||||
simInfo("script:" FAILED_PREFIX "%s" FAILED_POSTFIX ", " FAILED_PREFIX "failed" FAILED_POSTFIX ", error:%s",
|
||||
script->fileName, script->error);
|
||||
exit(-1);
|
||||
} else {
|
||||
simInfo("script:" SUCCESS_PREFIX "%s" SUCCESS_POSTFIX ", " SUCCESS_PREFIX
|
||||
"success" SUCCESS_POSTFIX,
|
||||
simInfo("script:" SUCCESS_PREFIX "%s" SUCCESS_POSTFIX ", " SUCCESS_PREFIX "success" SUCCESS_POSTFIX,
|
||||
script->fileName);
|
||||
simCloseTaosdConnect(script);
|
||||
simScriptSucced++;
|
||||
simScriptPos--;
|
||||
|
||||
simFreeScript(script);
|
||||
if (simScriptPos == -1) {
|
||||
simInfo("----------------------------------------------------------------------");
|
||||
simInfo("Simulation Test Done, " SUCCESS_PREFIX "%d" SUCCESS_POSTFIX " Passed:\n", simScriptSucced);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
simFreeScript(script);
|
||||
return simScriptList[simScriptPos];
|
||||
}
|
||||
} else {
|
||||
|
@ -147,7 +154,7 @@ void *simExecuteScript(void *inputScript) {
|
|||
simDebug("script:%s, line:%d with option \"%s\"", script->fileName, line->lineNum, option);
|
||||
|
||||
SCommand *cmd = &simCmdList[line->cmdno];
|
||||
int ret = (*(cmd->executeCmd))(script, option);
|
||||
int32_t ret = (*(cmd->executeCmd))(script, option);
|
||||
if (!ret) {
|
||||
script->killed = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue