def run(self): rowNum = 200 totalNum = 200 tdSql.prepare() tdLog.info("=============== step1") tdSql.execute("create table mt(ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int)") for i in range(5): tdSql.execute("create table tb%d using mt tags(%d)" % (i, i)) for j in range(rowNum): tdSql.execute("insert into tb%d values(now + %ds, %d, %d)" % (i, j, j, j)) time.sleep(0.1) tdLog.info("=============== step2") tdSql.query("select count(*), count(tbcol), count(tbcol2) from mt interval(10s)") tdSql.execute("create table st as select count(*), count(tbcol), count(tbcol2) from mt interval(10s)") tdLog.info("=============== step3") tdSql.waitedQuery("select * from st", 1, 120) v = tdSql.getData(0, 3) if v >= 51: tdLog.exit("value is %d, which is larger than 51" % v) tdLog.info("=============== step4") for i in range(5, 10): tdSql.execute("create table tb%d using mt tags(%d)" % (i, i)) for j in range(rowNum): tdSql.execute("insert into tb%d values(now + %ds, %d, %d)" % (i, j, j, j)) tdLog.info("=============== step5") tdLog.sleep(40) tdSql.waitedQuery("select * from st order by ts desc", 1, 120) v = tdSql.getData(0, 3) if v <= 51: tdLog.exit("value is %d, which is smaller than 51" % v)
def wildcardFilterOnTags(self): tdLog.debug("begin wildcardFilterOnTag") tdSql.prepare() tdSql.execute( "create table stb (ts timestamp, c1 int, c2 binary(10)) tags(t1 binary(10))" ) tdSql.execute("create table tb1 using stb tags('a1')") tdSql.execute("create table tb2 using stb tags('b2')") tdSql.execute("create table tb3 using stb tags('a3')") tdSql.execute( "create table strm as select count(*), avg(c1), first(c2) from stb where t1 like 'a%' interval(4s) sliding(2s)" ) tdSql.query("describe strm") tdSql.checkRows(4) tdLog.sleep(1) tdSql.execute("insert into tb1 values (now, 0, 'tb1')") tdLog.sleep(4) tdSql.execute("insert into tb2 values (now, 2, 'tb2')") tdLog.sleep(4) tdSql.execute("insert into tb3 values (now, 0, 'tb3')") tdSql.waitedQuery("select * from strm", 4, 60) tdSql.checkRows(4) tdSql.checkData(0, 2, 0.000000000) if tdSql.getData(0, 3) == 'tb2': tdLog.exit("unexpected value of data03") if tdSql.getData(1, 3) == 'tb2': tdLog.exit("unexpected value of data13") if tdSql.getData(2, 3) == 'tb2': tdLog.exit("unexpected value of data23") if tdSql.getData(3, 3) == 'tb2': tdLog.exit("unexpected value of data33") tdLog.info("add table tb4 to see if stream still works correctly") # The vnode client needs to refresh metadata cache to allow strm calculate tb4's data. # But the current refreshing frequency is every 10 min # commented out the case below to save running time tdSql.execute("create table tb4 using stb tags('a4')") tdSql.execute("insert into tb4 values(now, 4, 'tb4')") tdSql.waitedQuery("select * from strm order by ts desc", 6, 60) tdSql.checkRows(6) tdSql.checkData(0, 2, 4) tdSql.checkData(0, 3, "tb4") tdLog.info("change tag values to see if stream still works correctly") tdSql.execute("alter table tb4 set tag t1='b4'") tdLog.sleep(3) tdSql.execute("insert into tb1 values (now, 1, 'tb1_a1')") tdLog.sleep(4) tdSql.execute("insert into tb4 values (now, -4, 'tb4_b4')") tdSql.waitedQuery("select * from strm order by ts desc", 8, 100) tdSql.checkRows(8) tdSql.checkData(0, 2, 1) tdSql.checkData(0, 3, "tb1_a1")
def run(self): nodes = Nodes() ctest = ClusterTest(nodes.node1.hostName) ctest.connectDB() ctest.createSTable(3) ctest.run() tdSql.init(ctest.conn.cursor(), False) nodes.node2.stopTaosd() tdSql.execute("use %s" % ctest.dbName) tdSql.query("show vgroups") vnodeID = tdSql.getData(0, 0) nodes.node2.removeDataForVnode(vnodeID) nodes.node2.startTaosd() # Wait for vnode file to recover for i in range(10): tdSql.query("select count(*) from t0") tdLog.sleep(10) for i in range(10): tdSql.query("select count(*) from t0") tdSql.checkData(0, 0, 1000) tdSql.close() tdLog.success("%s successfully executed" % __file__)
def run(self): nodes = Nodes() nodes.addConfigs("maxVgroupsPerDb", "10") nodes.addConfigs("maxTablesPerVnode", "1000") nodes.restartAllTaosd() ctest = ClusterTest(nodes.node1.hostName) ctest.connectDB() ctest.createSTable(1) ctest.run() tdSql.init(ctest.conn.cursor(), False) tdSql.execute("use %s" % ctest.dbName) tdSql.query("show vgroups") dnodes = [] for i in range(10): dnodes.append(int(tdSql.getData(i, 4))) s = set(dnodes) if len(s) < 3: tdLog.exit("cluster is not balanced") tdLog.info("cluster is balanced") nodes.removeConfigs("maxVgroupsPerDb", "10") nodes.removeConfigs("maxTablesPerVnode", "1000") nodes.restartAllTaosd() tdSql.close() tdLog.success("%s successfully executed" % __file__)
def run(self): rowNum = 200 tdSql.prepare() ts_now = 1633017600000 tdLog.info("=============== step1") tdSql.execute("create table mt(ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int)") for i in range(5): tdSql.execute("create table tb%d using mt tags(%d)" % (i, i)) for j in range(rowNum): tdSql.execute("insert into tb%d values(%d, %d, %d)" % (i, ts_now, j, j)) ts_now += 1000 time.sleep(0.1) tdLog.info("=============== step2") tdSql.query("select count(*), count(tbcol), count(tbcol2) from mt interval(10s)") tdSql.execute("create table st as select count(*), count(tbcol), count(tbcol2) from mt interval(10s)") tdLog.info("=============== step3") start = time.time() tdSql.waitedQuery("select * from st", 1, 180) delay = int(time.time() - start) + 80 v = tdSql.getData(0, 3) if v != 10: tdLog.exit("value is %d, expect is 10." % v) tdLog.info("=============== step4") for i in range(5, 10): tdSql.execute("create table tb%d using mt tags(%d)" % (i, i)) for j in range(rowNum): tdSql.execute("insert into tb%d values(%d, %d, %d)" % (i, ts_now, j, j)) ts_now += 1000 tdLog.info("=============== step5") maxValue = 0 for i in range(delay): time.sleep(1) tdSql.query("select * from st order by ts desc") v = tdSql.getData(0, 3) if v > maxValue: maxValue = v if v >= 10: break if maxValue < 10: tdLog.exit("value is %d, expect is 10" % maxValue)
def run(self): tdSql.prepare() tdSql.execute( "create table t1(ts timestamp, c1 int, c2 float, c3 int, c4 int)") startTime = time.time() tdSql.execute("insert into t1 file 'outoforder.csv'") duration = time.time() - startTime print("Out of Order - Insert time: %d" % duration) tdSql.query("select count(*) from t1") rows = tdSql.getData(0, 0) tdSql.execute( "create table t2(ts timestamp, c1 int, c2 float, c3 int, c4 int)") startTime = time.time() tdSql.execute("insert into t2 file 'ordered.csv'") duration = time.time() - startTime print("Ordered - Insert time: %d" % duration) tdSql.query("select count(*) from t2") tdSql.checkData(0, 0, rows)