test: remove show databases check from insert cases (#11508)
* [TD-13558]<feature>: taos shell refactor add taosTools as submodule * add tools/taos-tools * add more client interface for taosTools compile * update taos-tools * update taos-tools * refactor shell * [TD-13558]<feature>: taos shell test speed * [TD-13558]<feature>: taos -n startup works * taos -n rpc works * taos -n server works * cleanup code since no endPort in 3.0 * update taos-tools * [TD-13558]<feature>: taos -C works * improve taos shell -c WIP * update taos-tools * add demoapi.c * adjust show databases result for 3.0 * test: add platform logic * add nchar * adjust taos_fetch_lengths * print fields * remove show databases check from insert cases
This commit is contained in:
parent
73884afd3e
commit
30799e59ce
|
@ -65,22 +65,32 @@ static void prepare_data(TAOS* taos) {
|
|||
usleep(100000);
|
||||
taos_select_db(taos, "test");
|
||||
|
||||
res = taos_query(taos, "create table meters(ts timestamp, f float, n int, b binary(20)) tags(area int, localtion binary(20));");
|
||||
res = taos_query(taos, "create table meters(ts timestamp, f float, n int, b binary(20), c nchar(20)) tags(area int, city binary(20), dist nchar(20));");
|
||||
taos_free_result(res);
|
||||
|
||||
char command[1024] = {0};
|
||||
for (int64_t i = 0; i < g_num_of_tb; i ++) {
|
||||
sprintf(command, "create table t%"PRId64" using meters tags(%"PRId64", '%s');",
|
||||
i, i, (i%2)?"beijing":"shanghai");
|
||||
// sprintf(command, "create table t%"PRId64" using meters tags(%"PRId64", '%s', '%s');",
|
||||
// i, i, (i%2)?"beijing":"shanghai", (i%2)?"朝阳区":"黄浦区");
|
||||
sprintf(command, "create table t%"PRId64" using meters tags(%"PRId64", '%s', '%s');",
|
||||
i, i, (i%2)?"beijing":"shanghai", (i%2)?"chaoyang":"huangpu");
|
||||
res = taos_query(taos, command);
|
||||
if ((res) && (0 == taos_errno(res))) {
|
||||
okPrint("t%" PRId64 " created\n", i);
|
||||
} else {
|
||||
errorPrint("%s() LN%d: %s\n",
|
||||
__func__, __LINE__, taos_errstr(res));
|
||||
}
|
||||
taos_free_result(res);
|
||||
|
||||
int64_t j = 0;
|
||||
int64_t total = 0;
|
||||
int64_t affected;
|
||||
for (; j < g_num_of_rec -1; j ++) {
|
||||
sprintf(command, "insert into t%"PRId64" values(%" PRId64 ", %f, %"PRId64", '%c%d')",
|
||||
i, 1650000000000+j, (float)j, j, 'a'+(int)j%10, rand());
|
||||
sprintf(command, "insert into t%"PRId64" "
|
||||
"values(%" PRId64 ", %f, %"PRId64", '%c%d', '%c%d')",
|
||||
i, 1650000000000+j, (float)j, j, 'a'+(int)j%25, rand(),
|
||||
'z' - (int)j%25, rand());
|
||||
res = taos_query(taos, command);
|
||||
if ((res) && (0 == taos_errno(res))) {
|
||||
affected = taos_affected_rows(res);
|
||||
|
@ -91,7 +101,7 @@ static void prepare_data(TAOS* taos) {
|
|||
}
|
||||
taos_free_result(res);
|
||||
}
|
||||
sprintf(command, "insert into t%"PRId64" values(%" PRId64 ", NULL, NULL, NULL)",
|
||||
sprintf(command, "insert into t%"PRId64" values(%" PRId64 ", NULL, NULL, NULL, NULL)",
|
||||
i, 1650000000000+j+1);
|
||||
res = taos_query(taos, command);
|
||||
if ((res) && (0 == taos_errno(res))) {
|
||||
|
@ -107,12 +117,16 @@ static void prepare_data(TAOS* taos) {
|
|||
}
|
||||
}
|
||||
|
||||
static int print_result(TAOS_RES* res, int block) {
|
||||
static int print_result(char *tbname, TAOS_RES* res, int block) {
|
||||
int64_t num_rows = 0;
|
||||
TAOS_ROW row = NULL;
|
||||
int num_fields = taos_num_fields(res);
|
||||
TAOS_FIELD* fields = taos_fetch_fields(res);
|
||||
|
||||
for (int f = 0; f < num_fields; f++) {
|
||||
printf("fields[%d].name=%s, fields[%d].type=%d, fields[%d].bytes=%d\n",
|
||||
f, fields[f].name, f, fields[f].type, f, fields[f].bytes);
|
||||
}
|
||||
if (block) {
|
||||
warnPrint("%s() LN%d, call taos_fetch_block()\n", __func__, __LINE__);
|
||||
int rows = 0;
|
||||
|
@ -126,6 +140,16 @@ static int print_result(TAOS_RES* res, int block) {
|
|||
taos_print_row(temp, row, fields, num_fields);
|
||||
puts(temp);
|
||||
num_rows ++;
|
||||
|
||||
int* lengths = taos_fetch_lengths(res);
|
||||
if (lengths) {
|
||||
for (int c = 0; c < num_fields; c++) {
|
||||
printf("length of column %d is %d\n", c, lengths[c]);
|
||||
}
|
||||
} else {
|
||||
errorPrint("%s() LN%d: %s's lengths is NULL\n",
|
||||
__func__, __LINE__, tbname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,28 +158,21 @@ static int print_result(TAOS_RES* res, int block) {
|
|||
|
||||
static void verify_query(TAOS* taos) {
|
||||
// TODO: select count(tbname) from stable once stable query work
|
||||
//
|
||||
char tbname[193] = {0};
|
||||
char command[1024] = {0};
|
||||
|
||||
for (int64_t i = 0; i < g_num_of_tb; i++) {
|
||||
sprintf(command, "select * from t%"PRId64"", i);
|
||||
sprintf(tbname, "t%"PRId64"", i);
|
||||
sprintf(command, "select * from %s", tbname);
|
||||
TAOS_RES* res = taos_query(taos, command);
|
||||
|
||||
if (res) {
|
||||
if (0 == taos_errno(res)) {
|
||||
int field_count = taos_field_count(res);
|
||||
printf("field_count: %d\n", field_count);
|
||||
int* lengths = taos_fetch_lengths(res);
|
||||
if (lengths) {
|
||||
for (int c = 0; c < field_count; c++) {
|
||||
printf("length of column %d is %d\n", c, lengths[c]);
|
||||
}
|
||||
} else {
|
||||
errorPrint("%s() LN%d: t%"PRId64"'s lengths is NULL\n",
|
||||
__func__, __LINE__, i);
|
||||
}
|
||||
|
||||
int64_t rows = print_result(res, i % 2);
|
||||
printf("rows is: %"PRId64"\n", rows);
|
||||
int64_t rows = print_result(tbname, res, i % 2);
|
||||
printf("rows is: %"PRId64"\n", rows);
|
||||
|
||||
} else {
|
||||
errorPrint("%s() LN%d: %s\n",
|
||||
|
|
|
@ -54,10 +54,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 9223372036854770000)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
# convert end
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -75,10 +75,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 2.000000000)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
# convert end
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -91,10 +91,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 2)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
# convert end
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
self.ts = 1607281690000
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
|
||||
# TS-806
|
||||
tdLog.info("test case for TS-806")
|
||||
|
||||
# Case 1
|
||||
tdSql.execute("create table t1(ts timestamp, c1 int)")
|
||||
tdSql.execute("insert into t1(c1, ts) values(1, %d)" % self.ts)
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
# Case 2
|
||||
tdSql.execute(
|
||||
"insert into t1(c1, ts) values(2, %d)(3, %d)" %
|
||||
(self.ts + 1000, self.ts + 2000))
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
# Case 3
|
||||
tdSql.execute("create table t2(ts timestamp, c1 timestamp)")
|
||||
tdSql.execute(
|
||||
" insert into t2(c1, ts) values(%d, %d)" %
|
||||
(self.ts, self.ts + 5000))
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.execute(
|
||||
" insert into t2(c1, ts) values(%d, %d)(%d, %d)" %
|
||||
(self.ts, self.ts + 6000, self.ts + 3000, self.ts + 8000))
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
# Case 4
|
||||
tdSql.execute(
|
||||
"create table stb(ts timestamp, c1 int, c2 binary(20)) tags(tstag timestamp, t1 int)")
|
||||
tdSql.execute(
|
||||
"insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', %d, 1)" %
|
||||
self.ts)
|
||||
tdSql.query("select * from stb")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
# Case 5
|
||||
tdSql.execute(
|
||||
"insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', now, 1) tb2(c1, ts) using stb tags(now + 2m, 1000) values(1, now - 1h)")
|
||||
tdSql.query("select * from stb")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.execute(" insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', now + 10s, 1) tb2(c1, ts) using stb(tstag) tags(now + 2m) values(1, now - 3h)(2, now - 2h)")
|
||||
tdSql.query("select * from stb")
|
||||
tdSql.checkRows(6)
|
||||
|
||||
# Case 6
|
||||
tdSql.execute(
|
||||
"create table stb2 (ts timestamp, c1 timestamp, c2 timestamp) tags(t1 timestamp, t2 timestamp)")
|
||||
tdSql.execute(" insert into tb4(c1, c2, ts) using stb2(t2, t1) tags(now, now + 1h) values(now + 1s, now + 2s, now + 3s)(now -1s, now - 2s, now - 3s) tb5(c2, ts, c1) using stb2(t2) tags(now + 1h) values(now, now, now)")
|
||||
tdSql.query("select * from stb2")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -91,10 +91,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 2)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
# convert end
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -93,10 +93,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 2)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
# convert end
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -93,10 +93,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 2)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
# convert end
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -93,10 +93,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 2)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
# convert end
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -91,10 +91,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 2)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -4,10 +4,32 @@ ulimit -c unlimited
|
|||
# insert
|
||||
python3 ./test.py $1 -f insert/basic.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/bool.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/tinyint.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/smallint.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/int.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/bigint.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/float.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/double.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/nchar.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/timestamp.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/unsignedTinyint.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/unsignedSmallint.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/unsignedInt.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/unsignedBigint.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/multi.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
|
||||
|
|
Loading…
Reference in New Issue