################################################################### # 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 random import os import time import taos import subprocess from faker import Faker from util.log import tdLog from util.cases import tdCases from util.sql import tdSql from util.dnodes import tdDnodes from util.dnodes import * class TDTestCase: def init(self, conn, logSql, replicaVar): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) self.testcasePath = os.path.split(__file__)[0] self.testcaseFilename = os.path.split(__file__)[-1] os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) self.db = "sel_null" def insert_data(self,database,vgroups): num_random = 10 tdSql.execute('''drop database if exists %s ;''' %database) tdSql.execute('''create database %s keep 36500 vgroups %d PRECISION 'us';'''%(database,vgroups)) tdSql.execute('''use %s;'''%database) tdSql.execute('''create stable %s.stb0 (ts timestamp , c0 int , c1 double , c0null int , c1null double ) tags( t0 tinyint , t1 varchar(16) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint , t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);'''%database) for i in range(5): tdSql.execute('''create table %s.stb0_%d using %s.stb0 tags(%d,'varchar%d',%d,%d, %d, %d,%d,'binary%d','nchar%d',%d,%d,%d ) ;'''%(database,i,database,i,i,i,i,i,i,i,i,i,i,i,i)) # insert data for i in range(num_random): for j in range(50): tdSql.execute('''insert into %s.stb0_0 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j)) tdSql.execute('''insert into %s.stb0_1 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j)) tdSql.execute('''insert into %s.stb0_2 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j)) tdSql.execute('''insert into %s.stb0_3 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j)) tdSql.execute('''insert into %s.stb0_4 (ts , c1 , c0) values(now, %d, %d) ;''' % (database,j,j)) tdSql.query("select count(*) from %s.stb0;" %database) tdSql.checkData(0,0,5*num_random*50) tdSql.query("select count(*) from %s.stb0_0;"%database) tdSql.checkData(0,0,num_random*50) def ts_3085(self,database): sql = "select count(c0null) from(select * from %s.stb0 limit 20,4) "%(database) tdSql.query(sql) tdSql.checkData(0,0,0) offset = random.randint(10,100) for i in range(offset): sql = "select count(c0null) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i) tdSql.query(sql) tdSql.checkData(0,0,0) sql = "select count(c1null) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i) tdSql.query(sql) tdSql.checkData(0,0,0) sql = "select count(c0) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i) tdSql.query(sql) tdSql.checkData(0,0,i) sql = "select count(c1) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i) tdSql.query(sql) tdSql.checkData(0,0,i) sql = "select count(t0) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i) tdSql.query(sql) tdSql.checkData(0,0,i) sql = "select count(t1) from(select * from %s.stb0 limit %d,%d) "%(database,offset,i) tdSql.query(sql) tdSql.checkData(0,0,i) def ts_2974_max(self,database): sql = "select max(c0) from %s.stb0 where ts