提交 b5e4861c 编写于 作者: wmmhello's avatar wmmhello

fix:add test cases for odbc interface

上级 8af5230b
......@@ -698,10 +698,8 @@ int taos_get_current_db(TAOS *taos, char *database, int len, int *required) {
if(database == NULL || len <= 0){
if(required != NULL) *required = strlen(pTscObj->db) + 1;
terrno = TSDB_CODE_INVALID_PARA;
return -1;
}
if(len < strlen(pTscObj->db) + 1){
code = -1;
}else if(len < strlen(pTscObj->db) + 1){
tstrncpy(database, pTscObj->db, len);
if(required) *required = strlen(pTscObj->db) + 1;
terrno = TSDB_CODE_INVALID_PARA;
......
......@@ -1044,6 +1044,7 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_null_none.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_null_none.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/odbc.py
,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-20582.py
......
import taos
import sys
import datetime
import inspect
from util.log import *
from util.sql import *
from util.cases import *
from util.common import tdCom
class TDTestCase:
def init(self, conn, logSql, replicaVar=1):
self.replicaVar = int(replicaVar)
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor(), False)
def check_ins_cols(self):
tdSql.execute("create database if not exists db")
tdSql.execute("create table db.ntb (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 tinyint unsigned, c7 smallint unsigned, c8 int unsigned, c9 bigint unsigned, c10 float, c11 double, c12 varchar(100), c13 nchar(100))")
tdSql.execute("create table db.stb (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 tinyint unsigned, c7 smallint unsigned, c8 int unsigned, c9 bigint unsigned, c10 float, c11 double, c12 varchar(100), c13 nchar(100)) tags(t int)")
tdSql.execute("insert into db.ctb using db.stb tags(1) (ts, c1) values (now, 1)")
tdSql.query("select count(*) from information_schema.ins_columns")
tdSql.checkData(0, 0, 265)
tdSql.query("select * from information_schema.ins_columns where table_name = 'ntb'")
tdSql.checkRows(14)
tdSql.checkData(0, 2, "NORMAL_TABLE")
tdSql.query("select * from information_schema.ins_columns where table_name = 'stb'")
tdSql.checkRows(14)
tdSql.checkData(0, 2, "SUPER_TABLE")
tdSql.query("select db_name,table_type,col_name,col_type,col_length from information_schema.ins_columns where table_name = 'ctb'")
tdSql.checkRows(14)
tdSql.checkData(0, 0, "db")
tdSql.checkData(1, 1, "CHILD_TABLE")
tdSql.checkData(3, 2, "c3")
tdSql.checkData(4, 3, "INT")
tdSql.checkData(5, 4, 8)
tdSql.query("desc information_schema.ins_columns")
tdSql.checkRows(9)
tdSql.checkData(0, 0, "table_name")
tdSql.checkData(5, 0, "col_length")
tdSql.checkData(1, 2, 64)
def check_get_db_name(self):
buildPath = tdCom.getBuildPath()
cmdStr = '%s/build/bin/get_db_name_test'%(buildPath)
tdLog.info(cmdStr)
ret = os.system(cmdStr)
if ret != 0:
tdLog.exit("sml_test get_db_name_test != 0")
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdSql.prepare(replica = self.replicaVar)
tdLog.printNoPrefix("==========start check_ins_cols run ...............")
self.check_ins_cols()
tdLog.printNoPrefix("==========end check_ins_cols run ...............")
tdLog.printNoPrefix("==========start check_get_db_name run ...............")
self.check_get_db_name()
tdLog.printNoPrefix("==========end check_get_db_name run ...............")
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())
......@@ -4,6 +4,7 @@ add_executable(tmq_sim tmqSim.c)
add_executable(create_table createTable.c)
add_executable(tmq_taosx_ci tmq_taosx_ci.c)
add_executable(sml_test sml_test.c)
add_executable(get_db_name_test get_db_name_test.c)
target_link_libraries(
create_table
PUBLIC taos_static
......@@ -40,3 +41,11 @@ target_link_libraries(
PUBLIC common
PUBLIC os
)
target_link_libraries(
get_db_name_test
PUBLIC taos_static
PUBLIC util
PUBLIC common
PUBLIC os
)
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "taos.h"
#include "types.h"
#include "tlog.h"
int get_db_test() {
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db");
taos_free_result(pRes);
pRes = taos_query(taos, "use sml_db");
int code = taos_errno(pRes);
taos_free_result(pRes);
ASSERT(code == 0);
code = taos_get_current_db(taos, NULL, 0, NULL);
ASSERT(code != 0);
int required = 0;
code = taos_get_current_db(taos, NULL, 0, &required);
ASSERT(code != 0);
ASSERT(required == 7);
char database[10] = {0};
code = taos_get_current_db(taos, database, 3, &required);
ASSERT(code != 0);
ASSERT(required == 7);
ASSERT(strcpy(database, "sm"));
char database1[10] = {0};
code = taos_get_current_db(taos, database1, 10, &required);
ASSERT(code == 0);
ASSERT(strcpy(database1, "sml_db"));
taos_close(taos);
return code;
}
int main(int argc, char *argv[]) {
int ret = 0;
ret = get_db_test();
ASSERT(!ret);
return ret;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册