diff --git a/tests/pytest/insert/bigint.py b/tests/pytest/insert/bigint.py new file mode 100644 index 0000000000000000000000000000000000000000..214200900a569c9336d5ee05bd088cbd405bb965 --- /dev/null +++ b/tests/pytest/insert/bigint.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed bigint)') + tdSql.execute('create table tb (ts timestamp, speed bigint)') + tdLog.info("insert into tb values (now, -9223372036854770000)") + tdSql.execute("insert into tb values (now, -9223372036854770000)") + tdLog.info('select * from tb') + tdSql.query('select * from tb') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('tdSql.checkData(0, 1, -9223372036854770000)') + tdSql.checkData(0, 1, -9223372036854770000) + tdLog.info('=============== step2') + tdLog.info("insert into tb values (now+1a, -9223372036854770000)") + tdSql.execute("insert into tb values (now+1a, -9223372036854770000)") + tdLog.info('select * from tb') + tdSql.query('select * from tb') + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('tdSql.checkData(0, 1, -9223372036854770000)') + tdSql.checkData(0, 1, -9223372036854770000) + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now+2a, 9223372036854770000)") + tdSql.execute("insert into tb values (now+2a, 9223372036854770000)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(3)') + tdSql.checkRows(3) + tdLog.info('tdSql.checkData(0, 1, 9223372036854770000)') + tdSql.checkData(0, 1, 9223372036854770000) + tdLog.info('=============== step4') + tdLog.info("insert into tb values (now+3a, 9223372036854770000)") + tdSql.execute("insert into tb values (now+3a, 9223372036854770000)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + tdLog.info('tdSql.checkData(0, 1, 9223372036854770000)') + tdSql.checkData(0, 1, 9223372036854770000) + tdLog.info('drop database db') + tdSql.execute('drop database db') + tdLog.info('show databases') + tdSql.query('show databases') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/bool.py b/tests/pytest/insert/bool.py new file mode 100644 index 0000000000000000000000000000000000000000..062563f4ab84c9e09ea3ed08ced60fac53b1add8 --- /dev/null +++ b/tests/pytest/insert/bool.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed bool)') + tdSql.execute('create table tb (ts timestamp, speed bool)') + tdLog.info("insert into tb values (now, true)") + tdSql.execute("insert into tb values (now, true)") + tdLog.info('select * from tb') + tdSql.query('select * from tb') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('=============== step2') + tdLog.info("insert into tb values (now+1m, 1)") + tdSql.execute("insert into tb values (now+1m, 1)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now+2m, 2)") + tdSql.execute("insert into tb values (now+2m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(3)') + tdSql.checkRows(3) + tdLog.info('=============== step4') + tdLog.info("insert into tb values (now+3m, 0)") + tdSql.execute("insert into tb values (now+3m, 0)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + tdLog.info('=============== step5') + tdLog.info("insert into tb values (now+4m, -1)") + tdSql.execute("insert into tb values (now+4m, -1)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + tdLog.info('=============== step6') + tdLog.info("insert into tb values (now+5m, false)") + tdSql.execute("insert into tb values (now+5m, false)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(6)') + tdSql.checkRows(6) +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/double.py b/tests/pytest/insert/double.py new file mode 100644 index 0000000000000000000000000000000000000000..19be9653c0852b541de8d2430640b23c85ee7e86 --- /dev/null +++ b/tests/pytest/insert/double.py @@ -0,0 +1,90 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed double)') + tdSql.execute('create table tb (ts timestamp, speed double)') + tdLog.info('=============== step2') + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now+2a, 2.85)") + tdSql.execute("insert into tb values (now+2a, 2.85)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('tdSql.checkData(0, 1, 2.850000000)') + tdSql.checkData(0, 1, 2.850000000) + tdLog.info('=============== step4') + tdLog.info("insert into tb values (now+3a, 3.4)") + tdSql.execute("insert into tb values (now+3a, 3.4)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('tdSql.checkData(0, 1, 3.400000000)') + tdSql.checkData(0, 1, 3.400000000) + tdLog.info('=============== step5') + tdLog.info("insert into tb values (now+4a, a2) -x step51") + tdSql.error("insert into tb values (now+4a, a2)1") + tdLog.info("insert into tb values (now+4a, 0)") + tdSql.execute("insert into tb values (now+4a, 0)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(3)') + tdSql.checkRows(3) + tdLog.info('tdSql.checkData(0, 1, 0.000000000)') + tdSql.checkData(0, 1, 0.000000000) + tdLog.info('=============== step6') + tdLog.info("insert into tb values (now+5a, 2a) -x step6") + tdSql.error("insert into tb values (now+5a, 2a)") + tdLog.info("insert into tb values(now+5a, 2)") + tdSql.execute("insert into tb values(now+5a, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + tdLog.info('tdSql.checkData(0, 1, 2.000000000)') + tdSql.checkData(0, 1, 2.000000000) + tdLog.info('=============== step7') + tdLog.info("insert into tb values (now+6a, 2a'1) -x step7") + tdSql.error("insert into tb values (now+6a, 2a'1)") + tdLog.info("insert into tb values(now+6a, 2)") + tdSql.execute("insert into tb values(now+6a, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + tdLog.info('tdSql.checkData(0, 1, 2.000000000)') + tdSql.checkData(0, 1, 2.000000000) + tdLog.info('drop database db') + tdSql.execute('drop database db') + tdLog.info('show databases') + tdSql.query('show databases') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/smallint.py b/tests/pytest/insert/smallint.py new file mode 100644 index 0000000000000000000000000000000000000000..0d85e45cfa82866542d2bf465624983155992f7c --- /dev/null +++ b/tests/pytest/insert/smallint.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed smallint)') + tdSql.execute('create table tb (ts timestamp, speed smallint)') + tdLog.info("insert into tb values (now, NULL)") + tdSql.execute("insert into tb values (now, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step2') + tdLog.info("insert into tb values (now+1m, -32768) -x step2") + tdSql.error("insert into tb values (now+1m, -32768)") + tdLog.info("insert into tb values (now+1m, NULL)") + tdSql.execute("insert into tb values (now+1m, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now+2m, 32767)") + tdSql.execute("insert into tb values (now+2m, 32767)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(3)') + tdSql.checkRows(3) + tdLog.info('tdSql.checkData(0, 1, 32767)') + tdSql.checkData(0, 1, 32767) + tdLog.info('=============== step4') + tdLog.info("insert into tb values (now+3m, 32768) -x step4") + tdSql.error("insert into tb values (now+3m, 32768)") + tdLog.info("insert into tb values (now+3m, NULL)") + tdSql.execute("insert into tb values (now+3m, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step5') + tdLog.info("insert into tb values (now+4m, a2)") + tdSql.error("insert into tb values (now+4m, a2)") + tdLog.info("insert into tb values (now+4m, 0)") + tdSql.execute("insert into tb values (now+4m, 0)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + tdLog.info('tdSql.checkData(0, 1, 0)') + tdSql.checkData(0, 1, 0) + tdLog.info('=============== step6') + tdLog.info("insert into tb values (now+5m, 2a)") + tdSql.error("insert into tb values (now+5m, 2a)") + tdLog.info("insert into tb values (now+5m, 2)") + tdSql.execute("insert into tb values (now+5m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(6)') + tdSql.checkRows(6) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('=============== step7') + tdLog.info("insert into tb values (now+6m, 2a'1)") + tdSql.error("insert into tb values (now+6m, 2a'1)") + tdLog.info("insert into tb values (now+6m, 2)") + tdSql.execute("insert into tb values (now+6m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(7)') + tdSql.checkRows(7) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('drop database db') + tdSql.execute('drop database db') + tdLog.info('show databases') + tdSql.query('show databases') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/tinyint.py b/tests/pytest/insert/tinyint.py new file mode 100644 index 0000000000000000000000000000000000000000..6d7178054e749f99a1ee6f40097f67ecc74a4c63 --- /dev/null +++ b/tests/pytest/insert/tinyint.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + tdSql.prepare() + + tdLog.info('=============== step1') + tdLog.info('create table tb (ts timestamp, speed tinyint)') + tdSql.execute('create table tb (ts timestamp, speed tinyint)') + tdLog.info("insert into tb values (now, NULL)") + tdSql.execute("insert into tb values (now, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(1)') + tdSql.checkRows(1) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step2') + tdLog.info("insert into tb values (now+1m, -128) -x step2") + tdSql.error("insert into tb values (now+1m, -128) ") + tdLog.info("insert into tb values (now+1m, NULL)") + tdSql.execute("insert into tb values (now+1m, NULL)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(2)') + tdSql.checkRows(2) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step3') + tdLog.info("insert into tb values (now+2m, 127)") + tdSql.execute("insert into tb values (now+2m, 127)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(3)') + tdSql.checkRows(3) + tdLog.info('tdSql.checkData(0, 1, 127)') + tdSql.checkData(0, 1, 127) + tdLog.info('=============== step4') + tdLog.info("insert into tb values (now+3m, 128) -x step4") + tdSql.error("insert into tb values (now+3m, 128)") + tdLog.info("insert into tb values (now+3m, NULL)") + tdSql.execute("insert into tb values (now+3m, NULL)") + tdLog.info('select * from tb') + tdSql.query('select * from tb') + tdLog.info('tdSql.checkRow(4)') + tdSql.checkRows(4) + tdLog.info('tdSql.checkData(0, 1, null)') + tdSql.checkData(0, 1, None) + tdLog.info('=============== step5') + tdLog.info("insert into tb values (now+4m, a2)") + tdSql.error("insert into tb values (now+4m, a2)") + tdLog.info("insert into tb values (now+4m, 0)") + tdSql.execute("insert into tb values (now+4m, 0)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(5)') + tdSql.checkRows(5) + tdLog.info('tdSql.checkData(0, 1, 0)') + tdSql.checkData(0, 1, 0) + tdLog.info('=============== step6') + tdLog.info("insert into tb values (now+5m, 2a)") + tdSql.error("insert into tb values (now+5m, 2a)") + tdLog.info("insert into tb values (now+5m, 2)") + tdSql.execute("insert into tb values (now+5m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(6)') + tdSql.checkRows(6) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('=============== step7') + tdLog.info("insert into tb values (now+6m, 2a'1)") + tdSql.error("insert into tb values (now+6m, 2a'1)") + tdLog.info("insert into tb values (now+6m, 2)") + tdSql.execute("insert into tb values (now+6m, 2)") + tdLog.info('select * from tb order by ts desc') + tdSql.query('select * from tb order by ts desc') + tdLog.info('tdSql.checkRow(7)') + tdSql.checkRows(7) + tdLog.info('tdSql.checkData(0, 1, 2)') + tdSql.checkData(0, 1, 2) + tdLog.info('drop database db') + tdSql.execute('drop database db') + tdLog.info('show databases') + tdSql.query('show databases') + tdLog.info('tdSql.checkRow(0)') + tdSql.checkRows(0) +# convert end + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/simpletest.sh b/tests/pytest/simpletest.sh index 58345e13ee8387c824fadb670f8fc99cd9e7f8a2..73b25d2056d55f4650930b53aa78c53cd181f374 100755 --- a/tests/pytest/simpletest.sh +++ b/tests/pytest/simpletest.sh @@ -1,9 +1,25 @@ #!/bin/bash -python3 ./test.py -f insert/basic.py $1 +python3 ./test.py $1 -f insert/basic.py python3 ./test.py -s $1 sleep 1 -python3 ./test.py -f insert/int.py $1 +python3 ./test.py $1 -f insert/int.py python3 ./test.py -s $1 sleep 1 -python3 ./test.py -f insert/float.py $1 +python3 ./test.py $1 -f insert/float.py python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f insert/bigint.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f insert/bool.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f insert/double.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f insert/smallint.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f insert/tinyint.py +python3 ./test.py -s $1 +sleep 1 diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index 00084681306da30e0a46333030a45c891c7780e4..edfee4ddb11337b45357022fd195063d3bcf134b 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -89,7 +89,12 @@ class TDSql: tdLog.exit( "sql:%.40s row:%d col:%d data:%s != expect:%s" % (self.sql, row, col, self.queryResult[row][col], data)) - tdLog.info("sql:%.40s, row:%d col:%d data:%s == expect:%d" % + + if data is None: + tdLog.info("sql:%.40s, row:%d col:%d data:%s == expect:%s" % + (self.sql, row, col, self.queryResult[row][col], data)) + else: + tdLog.info("sql:%.40s, row:%d col:%d data:%s == expect:%d" % (self.sql, row, col, self.queryResult[row][col], data)) def getData(self, row, col):