From eb4659d8d7aa9d63e25289bc8211044e80c477d0 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Fri, 11 Sep 2020 15:01:25 +0800 Subject: [PATCH 1/2] [TD-1389] : Update null value test --- tests/pytest/query/queryNormal.py | 2 ++ tests/pytest/query/queryNullValueTest.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/tests/pytest/query/queryNormal.py b/tests/pytest/query/queryNormal.py index 1ab285bbad..208ac54ecd 100644 --- a/tests/pytest/query/queryNormal.py +++ b/tests/pytest/query/queryNormal.py @@ -42,6 +42,8 @@ class TDTestCase: # join 3 tables -- bug exists tdSql.error("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_p.id, stb_p.dscrption, stb_p.pressure,stb_v.velocity from stb_p, stb_t, stb_v where stb_p.ts=stb_t.ts and stb_p.ts=stb_v.ts and stb_p.id = stb_t.id") + tdSql.error("select * from stb1 whern c1 > 'test' limit 100") + # query show stable tdSql.query("show stables") tdSql.checkRows(1) diff --git a/tests/pytest/query/queryNullValueTest.py b/tests/pytest/query/queryNullValueTest.py index f521f2e5e9..bc0b11827e 100644 --- a/tests/pytest/query/queryNullValueTest.py +++ b/tests/pytest/query/queryNullValueTest.py @@ -42,6 +42,9 @@ class TDTestCase: tdSql.prepare() for i in range(len(self.types)): + tdSql.execute("drop table if exists t0") + tdSql.execute("drop table if exists t1") + print("======== checking type %s ==========" % self.types[i]) tdSql.execute("create table t0 (ts timestamp, col %s)" % self.types[i]) tdSql.execute("insert into t0 values (%d, NULL)" % (self.ts)) From ada7c188fa92bed67f4db28cef4e8b7d648b41ca Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Sun, 13 Sep 2020 23:15:51 +0800 Subject: [PATCH 2/2] [TD-1329] add test case for incorrect count query --- tests/pytest/queryCount.py | 91 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 tests/pytest/queryCount.py diff --git a/tests/pytest/queryCount.py b/tests/pytest/queryCount.py new file mode 100644 index 0000000000..3281c09269 --- /dev/null +++ b/tests/pytest/queryCount.py @@ -0,0 +1,91 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +import threading +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class QueryCountMultiThread: + def initConnection(self): + self.records = 10000000 + self.numOfTherads = 50 + self.ts = 1537146000000 + self.host = "127.0.0.1" + self.user = "root" + self.password = "taosdata" + self.config = "/home/xp/git/TDengine/sim/dnode1/cfg" + self.conn = taos.connect( + self.host, + self.user, + self.password, + self.config) + + def insertData(self, threadID): + cursor = self.conn.cursor() + print("Thread %d: starting" % threadID) + base = 200000 * threadID + for i in range(200): + query = "insert into tb values" + for j in range(1000): + query += "(%d, %d, 'test')" % (self.ts + base + i * 1000 + j, base + i * 1000 + j) + cursor.execute(query) + cursor.close() + print("Thread %d: finishing" % threadID) + + def run(self): + tdDnodes.init("") + tdDnodes.setTestCluster(False) + tdDnodes.setValgrind(False) + + tdDnodes.stopAll() + tdDnodes.deploy(1) + tdDnodes.start(1) + + cursor = self.conn.cursor() + cursor.execute("drop database if exists db") + cursor.execute("create database db") + cursor.execute("use db") + cursor.execute("create table tb (ts timestamp, id int, name nchar(30))") + cursor.close() + + threads = [] + for i in range(50): + thread = threading.Thread(target=self.insertData, args=(i,)) + threads.append(thread) + thread.start() + + for i in range(50): + threads[i].join() + + cursor = self.conn.cursor() + cursor.execute("use db") + sql = "select count(*) from tb" + cursor.execute(sql) + data = cursor.fetchall() + + if(data[0][0] == 10000000): + tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%d" % (sql, 0, 0, data[0][0], 10000000)) + else: + tdLog.exit("sql:%s, row:%d col:%d data:%d == expect:%d" % (sql, 0, 0, data[0][0], 10000000)) + + cursor.close() + self.conn.close() + +q = QueryCountMultiThread() +q.initConnection() +q.run() \ No newline at end of file