diff --git a/tests/develop-test/1-insert/0-sql/batchInsert.py b/tests/develop-test/1-insert/0-sql/batchInsert.py index f09c14b9be277fb7bbb684b7e0e1d1c5b932eaf5..22b1b5250b844648541b90361ec36cbf4da6c94f 100644 --- a/tests/develop-test/1-insert/0-sql/batchInsert.py +++ b/tests/develop-test/1-insert/0-sql/batchInsert.py @@ -15,6 +15,7 @@ import sys from util.log import * from util.cases import * from util.sql import * +from util.dnodes import * class TDTestCase: @@ -23,22 +24,32 @@ class TDTestCase: case1: [TS-854] normal table batch insert with binding same table, different number of columns and timestamp in ascending order case2: [TS-854] normal table batch insert with binding same table, different number of columns and timestamp in descending order case3: [TS-854] normal table batch insert with binding same table, different number of columns and timestamp out of order - case4: [TS-854] normal table batch insert with binding same table, different number of columns and timestamp overriding + case4: [TS-854] normal table batch insert with binding same table, different number of columns and same timestamp case5: [TS-854] normal table batch insert with binding different tables, different number of columns and timestamp in ascending order case6: [TS-854] normal table batch insert with binding different tables, different number of columns and timestamp in descending order case7: [TS-854] normal table batch insert with binding different tables, different number of columns and timestamp out of order - case8: [TS-854] normal table batch insert with binding different tables, different number of columns and timestamp overriding + case8: [TS-854] normal table batch insert with binding different tables, different number of columns and same timestamp case9: [TS-854] sub table batch insert with binding same table, different number of columns and timestamp in ascending order case10: [TS-854] sub table batch insert with binding same table, different number of columns and timestamp in descending order case11: [TS-854] sub table batch insert with binding same table, different number of columns and timestamp out of order - case12: [TS-854] sub table batch insert with binding same table, different number of columns and timestamp overriding + case12: [TS-854] sub table batch insert with binding same table, different number of columns and same timestamp case13: [TS-854] sub table batch insert with binding different tables, different number of columns and timestamp in ascending order case14: [TS-854] sub table batch insert with binding different tables, different number of columns and timestamp in descending order case15: [TS-854] sub table batch insert with binding different tables, different number of columns and timestamp out of order - case16: [TS-854] sub table batch insert with binding different tables, different number of columns and timestamp overriding + case16: [TS-854] sub table batch insert with binding different tables, different number of columns and same timestamp + + case17: [TS-854] sub table batch insert with binding same table, different number of columns, different number of tags and timestamp in ascending order + case18: [TS-854] sub table batch insert with binding same table, different number of columns, different number of tags and timestamp in descending order + case19: [TS-854] sub table batch insert with binding same table, different number of columns, different number of tags and timestamp out of order + case20: [TS-854] sub table batch insert with binding same table, different number of columns, different number of tags and same timestamp + + case21: [TS-854] sub table batch insert with binding different tables, different number of columns, different number of tags and timestamp in ascending order + case22: [TS-854] sub table batch insert with binding different tables, different number of columns, different number of tags and timestamp in descending order + case23: [TS-854] sub table batch insert with binding different tables, different number of columns, different number of tags and timestamp out of order + case24: [TS-854] sub table batch insert with binding different tables, different number of columns, different number of tags and same timestamp ''' return @@ -50,7 +61,7 @@ class TDTestCase: def run(self): tdSql.prepare() - tdSql.execute("create table tb1(ts timestamp, c1 int, c2 int, c3 int, c4 int)") + tdSql.execute("create table tb1(ts timestamp, c1 double, c2 double, c3 double, c4 double)") args = [(self.ts + 1000, self.ts + 3000, self.ts + 5000, self.ts + 7000), (self.ts + 8000, self.ts + 6000, self.ts + 4000, self.ts + 2000), @@ -59,7 +70,7 @@ class TDTestCase: # case 1, 2, 3, 4 tdLog.info("test case for case 1, 2, 3, 4") - sql = "insert into tb1(ts, c1) values(%d, 0) tb1(ts, c1) values(%d, 0) tb1(ts, c1) values(%d, 0) tb1(ts, c1, c2, c3, c4) values(%d, 0, 0, 0, 0)" + sql = "insert into tb1(ts, c1) values(%d, 0.0) tb1(ts, c1) values(%d, 0.0) tb1(ts, c1) values(%d, 0.0) tb1(ts, c1, c2, c3, c4) values(%d, 0.0, 0.0, 0.0, 0.0)" i = 1 rows = 0 for arg in args: @@ -75,7 +86,12 @@ class TDTestCase: tdSql.query("select * from tb1") tdSql.checkRows(rows) i = i + 1 - + # restart taosd and check again + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from tb1") + tdSql.checkRows(rows) + # case 5, 6, 7, 8 tdSql.execute("create table tb2(ts timestamp, c1 int, c2 int, c3 int, c4 int)") tdSql.execute("create table tb3(ts timestamp, c1 double, c2 double, c3 double, c4 double)") @@ -96,11 +112,19 @@ class TDTestCase: tdSql.query("select * from tb3") tdSql.checkRows(rows) i = i + 1 + + # restart taosd and check again + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from tb2") + tdSql.checkRows(rows) + tdSql.query("select * from tb3") + tdSql.checkRows(rows) # case 9, 10, 11, 12 - tdSql.execute("create table stb(ts timestamp, c1 int, c2 int, c3 int, c4 int) tags(t1 nchar(20))") + tdSql.execute("create table stb(ts timestamp, c1 double, c2 double, c3 double, c4 double) tags(t1 nchar(20))") tdLog.info("test case for case 9, 10, 11, 12") - sql = "insert into t1(ts, c1) using stb tags('tag1') values(%d, 0) t1(ts, c1) using stb tags('tag1') values(%d, 0) t1(ts, c1) using stb tags('tag1') values(%d, 0) t1(ts, c1, c2, c3, c4) using stb tags('tag1') values(%d, 0, 0, 0, 0)" + sql = "insert into t1(ts, c1) using stb tags('tag1') values(%d, 0.0) t1(ts, c1) using stb tags('tag1') values(%d, 0.0) t1(ts, c1) using stb tags('tag1') values(%d, 0.0) t1(ts, c1, c2, c3, c4) using stb tags('tag1') values(%d, 0.0, 0.0, 0.0, 0.0)" rows = 0 for arg in args: tdLog.info("test case for case %d" % i) @@ -114,17 +138,77 @@ class TDTestCase: tdSql.checkRows(rows) i = i + 1 + # restart taosd and check again + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from stb") + tdSql.checkRows(rows) + # case 13, 14, 15, 16 tdSql.execute("create table stb2(ts timestamp, c1 int, c2 int, c3 int, c4 int) tags(t1 nchar(20))") tdSql.execute("create table stb3(ts timestamp, c1 double, c2 double, c3 double, c4 double) tags(t1 binary(20))") - tdLog.info("test case for case 5, 6, 7, 8") + tdLog.info("test case for case 13, 14, 15, 16") sql = "insert into t2(ts, c1) using stb2 tags('tag2') values(%d, 0) t2(ts, c1, c2, c3, c4) using stb2 tags('tag2') values(%d, 0, 0, 0, 0) t3(ts, c2) using stb3 tags('tag3') values(%d, 0.0) t3(ts, c1, c2, c3, c4) using stb3 tags('tag3') values(%d, 0.0, 0.0, 0.0, 0.0)" rows = 0 for arg in args: tdLog.info("test case for case %d" % i) tdLog.info(sql % arg) tdSql.execute(sql % arg) - if i == 8: + if i == 16: + rows = rows + 1 + else: + rows = rows + 2 + tdSql.query("select * from stb2") + tdSql.checkRows(rows) + tdSql.query("select * from stb3") + tdSql.checkRows(rows) + i = i + 1 + + # restart taosd and check again + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from stb2") + tdSql.checkRows(rows) + tdSql.query("select * from stb3") + tdSql.checkRows(rows) + + # case 17, 18, 19, 20 + tdSql.execute("drop table if exists stb") + tdSql.execute("create table stb(ts timestamp, c1 double, c2 double, c3 double, c4 double) tags(t1 nchar(20), t2 int, t3 binary(20))") + tdLog.info("test case for case 17, 18, 19, 20") + sql = "insert into t1(ts, c1) using stb(t1) tags('tag1') values(%d, 0.0) t1(ts, c1) using stb(t2) tags(1) values(%d, 0.0) t1(ts, c1) using stb(t1, t2) tags('tag1', 1) values(%d, 0.0) t1(ts, c1, c2, c3, c4) using stb(t1, t2, t3) tags('tag1', 1, 'tag3') values(%d, 0.0, 0.0, 0.0, 0.0)" + rows = 0 + for arg in args: + tdLog.info("test case for case %d" % i) + tdLog.info(sql % arg) + tdSql.execute(sql % arg) + if i == 20: + rows = rows + 1 + else: + rows = rows + 4 + tdSql.query("select * from stb") + tdSql.checkRows(rows) + i = i + 1 + + # restart taosd and check again + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from stb") + tdSql.checkRows(rows) + + # case 21, 22, 23, 24 + tdSql.execute("drop table if exists stb2") + tdSql.execute("drop table if exists stb3") + tdSql.execute("create table stb2(ts timestamp, c1 int, c2 int, c3 int, c4 int) tags(t1 nchar(20), t2 int)") + tdSql.execute("create table stb3(ts timestamp, c1 double, c2 double, c3 double, c4 double) tags(t1 binary(20), t2 double)") + tdLog.info("test case for case 21, 22, 23, 24") + sql = "insert into t2(ts, c1) using stb2(t1) tags('tag2') values(%d, 0) t2(ts, c1, c2, c3, c4) using stb2(t1, t2) tags('tag2', 1) values(%d, 0, 0, 0, 0) t3(ts, c2) using stb3(t1) tags('tag3') values(%d, 0.0) t3(ts, c1, c2, c3, c4) using stb3(t1, t2) tags('tag3', 0.0) values(%d, 0.0, 0.0, 0.0, 0.0)" + rows = 0 + for arg in args: + tdLog.info("test case for case %d" % i) + tdLog.info(sql % arg) + tdSql.execute(sql % arg) + if i == 24: rows = rows + 1 else: rows = rows + 2 @@ -133,11 +217,18 @@ class TDTestCase: tdSql.query("select * from stb3") tdSql.checkRows(rows) i = i + 1 + + # restart taosd and check again + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.query("select * from stb2") + tdSql.checkRows(rows) + tdSql.query("select * from stb3") + tdSql.checkRows(rows) def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) - tdCases.addWindows(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/fulltest.sh b/tests/develop-test/fulltest.sh index 5c3b225f3fa1e24a098bcfafb19981c58115c337..9ec1dd23ac27928950befc35bd49ba8b4e6270eb 100755 --- a/tests/develop-test/fulltest.sh +++ b/tests/develop-test/fulltest.sh @@ -1,2 +1,3 @@ python3 test.py -f 0-management/3-tag/json_tag.py python3 test.py -f 1-insert/0-sql/basic.py +python3 test.py -f 1-insert/0-sql/batchInsert.py \ No newline at end of file