未验证 提交 e2505fce 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #2304 from taosdata/feature/sangshuduo/TD-478

modify format by autopep8.
......@@ -35,20 +35,30 @@ class TDTestCase:
curType = self.types[i]
print("======= Verify filter for %s type =========" % (curType))
tdLog.debug(
"create table st%s(ts timestamp, num %s) tags(id %s)" % (curType, curType, curType))
"create table st%s(ts timestamp, num %s) tags(id %s)" %
(curType, curType, curType))
tdSql.execute(
"create table st%s(ts timestamp, num %s) tags(id %s)" % (curType, curType, curType))
"create table st%s(ts timestamp, num %s) tags(id %s)" %
(curType, curType, curType))
#create 10 tables, insert 10 rows for each table
# create 10 tables, insert 10 rows for each table
for j in range(self.rowNum):
tdSql.execute("create table st%s%d using st%s tags(%d)" % (curType, j + 1, curType, j + 1))
tdSql.execute(
"create table st%s%d using st%s tags(%d)" %
(curType, j + 1, curType, j + 1))
for k in range(self.rowNum):
tdSql.execute("insert into st%s%d values(%d, %d)" % (curType, j + 1, self.ts + k + 1, j * 10 + k + 1))
tdSql.error("insert into st%s10 values(%d, %d)" % (curType, self.ts + 11, pow(2, self.powers[i])))
tdSql.execute("insert into st%s10 values(%d, %d)" % (curType, self.ts + 12, pow(2, self.powers[i]) - 1))
tdSql.error("insert into st%s10 values(%d, %d)" % (curType, self.ts + 13, pow(-2, self.powers[i])))
tdSql.execute("insert into st%s10 values(%d, %d)" % (curType, self.ts + 14, pow(-2, self.powers[i]) + 1))
tdSql.execute(
"insert into st%s%d values(%d, %d)" %
(curType, j + 1, self.ts + k + 1, j * 10 + k + 1))
tdSql.error("insert into st%s10 values(%d, %d)" %
(curType, self.ts + 11, pow(2, self.powers[i])))
tdSql.execute("insert into st%s10 values(%d, %d)" %
(curType, self.ts + 12, pow(2, self.powers[i]) - 1))
tdSql.error("insert into st%s10 values(%d, %d)" %
(curType, self.ts + 13, pow(-2, self.powers[i])))
tdSql.execute("insert into st%s10 values(%d, %d)" %
(curType, self.ts + 14, pow(-2, self.powers[i]) + 1))
# > for int type on column
tdSql.query("select * from st%s where num > 50" % curType)
......@@ -106,7 +116,9 @@ class TDTestCase:
tdSql.query("select * from st%s where id != 5" % curType)
tdSql.checkRows(92)
print("======= Verify filter for %s type finished =========" % curType)
print(
"======= Verify filter for %s type finished =========" %
curType)
def stop(self):
tdSql.close()
......
......@@ -36,8 +36,8 @@ class TDTestCase:
"create table st(ts timestamp, num float, speed double) tags(tagcol1 float, tagcol2 double)")
for j in range(self.rowNum):
tdSql.execute(
"insert into st1 using st tags(1.1, 2.3) values(%d, %f, %f)" % (self.ts + j + 1, 1.1 * (j + 1), 2.3 * (j + 1)))
tdSql.execute("insert into st1 using st tags(1.1, 2.3) values(%d, %f, %f)" % (
self.ts + j + 1, 1.1 * (j + 1), 2.3 * (j + 1)))
# > for float type on column
tdSql.query("select * from st where num > 5.5")
......
......@@ -36,11 +36,17 @@ class TDTestCase:
tdSql.execute("create table st1 using st tags(true, 'table1', '水表')")
for i in range(1, 6):
tdSql.execute("insert into st1 values(%d, %d, 'taosdata%d', '涛思数据%d')" % (self.ts + i, i % 2, i, i))
tdSql.execute(
"insert into st1 values(%d, %d, 'taosdata%d', '涛思数据%d')" %
(self.ts + i, i %
2, i, i))
tdSql.execute("create table st2 using st tags(false, 'table2', '电表')")
for i in range(6, 11):
tdSql.execute("insert into st2 values(%d, %d, 'taosdata%d', '涛思数据%d')" % (self.ts + i, i % 2, i, i))
tdSql.execute(
"insert into st2 values(%d, %d, 'taosdata%d', '涛思数据%d')" %
(self.ts + i, i %
2, i, i))
# =============Verify stable columns====================
# > for bool type on column
......@@ -359,4 +365,3 @@ class TDTestCase:
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
......@@ -40,12 +40,11 @@ class TDTestCase:
tagcol6 double, tagcol7 bool, tagcol8 nchar(20), tagcol9 binary(20))''')
for i in range(self.rowNum):
tdSql.execute("create table st%d using st tags(%d, %d, %d, %d, %f, %f, %d, 'tag%d', '标签%d')" % (i + 1, i + 1, i + 1, i + 1, i + 1, 1.1 * (i + 1),
1.23 * (i + 1), (i + 1) % 2, i + 1, i + 1))
tdSql.execute("create table st%d using st tags(%d, %d, %d, %d, %f, %f, %d, 'tag%d', '标签%d')" % (
i + 1, i + 1, i + 1, i + 1, i + 1, 1.1 * (i + 1), 1.23 * (i + 1), (i + 1) % 2, i + 1, i + 1))
for j in range(self.rowNum):
tdSql.execute("insert into st%d values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')" % (i + 1, self.ts + 10 * (i + 1) + j + 1,
j + 1, j + 1, j + 1, j + 1, 1.1 * (j + 1), 1.23 * (j + 1), (j + 1) % 2, j + 1, j + 1))
tdSql.execute("insert into st%d values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')" % (
i + 1, self.ts + 10 * (i + 1) + j + 1, j + 1, j + 1, j + 1, j + 1, 1.1 * (j + 1), 1.23 * (j + 1), (j + 1) % 2, j + 1, j + 1))
print("======= step 2: verify order for each column =========")
# sort for timestamp in asc order
......@@ -56,19 +55,24 @@ class TDTestCase:
tdSql.query("select * from st order by ts desc")
tdSql.checkColumnSorted(0, "desc")
for i in range(1, 10):
tdSql.error("select * from st order by tbcol%d" % i)
tdSql.error("select * from st order by tbcol%d asc" % i)
tdSql.error("select * from st order by tbcol%d desc" % i)
tdSql.query("select avg(tbcol1) from st group by tagcol%d order by tagcol%d" % (i, i))
tdSql.query(
"select avg(tbcol1) from st group by tagcol%d order by tagcol%d" %
(i, i))
tdSql.checkColumnSorted(1, "")
tdSql.query("select avg(tbcol1) from st group by tagcol%d order by tagcol%d asc" % (i, i))
tdSql.query(
"select avg(tbcol1) from st group by tagcol%d order by tagcol%d asc" %
(i, i))
tdSql.checkColumnSorted(1, "asc")
tdSql.query("select avg(tbcol1) from st group by tagcol%d order by tagcol%d desc" % (i, i))
tdSql.query(
"select avg(tbcol1) from st group by tagcol%d order by tagcol%d desc" %
(i, i))
tdSql.checkColumnSorted(1, "desc")
def stop(self):
......
......@@ -97,6 +97,8 @@ class Test:
"create table %s using %s tags (1, '表1')" %
(current_tb, self.last_stb))
self.last_tb = current_tb
self.written = 0
tdSql.execute(
"insert into %s values (now, 27, '我是nchar字符串')" %
self.last_tb)
......
......@@ -48,7 +48,7 @@ python3 ./test.py -f tag_lite/float.py
python3 ./test.py -f tag_lite/int_binary.py
python3 ./test.py -f tag_lite/int_float.py
python3 ./test.py -f tag_lite/int.py
# python3 ./test.py -f tag_lite/set.py
python3 ./test.py -f tag_lite/set.py
python3 ./test.py -f tag_lite/smallint.py
python3 ./test.py -f tag_lite/tinyint.py
......
......@@ -18,7 +18,10 @@ class TDTestCase:
tdSql.prepare()
getTableNameLen = "grep -w '#define TSDB_TABLE_NAME_LEN' ../../src/inc/taosdef.h|awk '{print $3}'"
tableNameMaxLen = int( subprocess.check_output(getTableNameLen, shell=True)) - 1
tableNameMaxLen = int(
subprocess.check_output(
getTableNameLen,
shell=True)) - 1
tdLog.info("table name max length is %d" % tableNameMaxLen)
chars = string.ascii_uppercase + string.ascii_lowercase
tb_name = ''.join(random.choices(chars, k=tableNameMaxLen))
......
......@@ -93,9 +93,13 @@ class TDTestCase:
tdSql.error("alter table ta_ch_mt2 change tag tgcol1 tgcol2")
# TSIM: return -1
# TSIM: step22:
# TSIM: sql alter table $mt change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20
tdLog.info("alter table ta_ch_mt2 change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20")
tdSql.error("alter table ta_ch_mt2 change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20")
# TSIM: sql alter table $mt change tag tgcol1
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x
# step20
tdLog.info(
"alter table ta_ch_mt2 change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20")
tdSql.error(
"alter table ta_ch_mt2 change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20")
# TSIM: return -1
# TSIM: step20:
# TSIM:
......@@ -267,8 +271,10 @@ class TDTestCase:
tdSql.execute(
'create table ta_ch_mt6 (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))')
# TSIM: sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' )
tdLog.info("create table tb6 using ta_ch_mt6 tags( '1', 2, 3, '4', 5, '6' )")
tdSql.execute("create table tb6 using ta_ch_mt6 tags( '1', 2, 3, '4', 5, '6' )")
tdLog.info(
"create table tb6 using ta_ch_mt6 tags( '1', 2, 3, '4', 5, '6' )")
tdSql.execute(
"create table tb6 using ta_ch_mt6 tags( '1', 2, 3, '4', 5, '6' )")
# TSIM: sql insert into $tb values(now, 1)
tdLog.info("insert into tb6 values(now, 1)")
tdSql.execute("insert into tb6 values(now, 1)")
......
此差异已折叠。
......@@ -178,13 +178,13 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data23 != false then
tdLog.info('tdSql.checkData(2, 3, false)')
tdSql.checkData(2, 3, false)
tdLog.info('tdSql.checkData(2, 3, "TAG")')
tdSql.checkData(2, 3, "TAG")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data33 != 4 then
tdLog.info('tdSql.checkData(3, 3, 4)')
tdSql.checkData(3, 3, 4)
tdLog.info('tdSql.checkData(3, 3, "TAG")')
tdSql.checkData(3, 3, "TAG")
# TSIM: return -1
# TSIM: endi
# TSIM:
......@@ -458,8 +458,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
tdLog.info('tdSql.checkData(0, 3, "2")')
tdSql.checkData(0, 3, "2")
# TSIM: return -1
# TSIM: endi
# TSIM:
......@@ -495,8 +495,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data03 != 4 then
tdLog.info('tdSql.checkData(0, 3, 4)')
tdSql.checkData(0, 3, 4)
tdLog.info('tdSql.checkData(0, 3, "4")')
tdSql.checkData(0, 3, "4")
# TSIM: return -1
# TSIM: endi
# TSIM:
......@@ -521,8 +521,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data03 != 4 then
tdLog.info('tdSql.checkData(0, 3, 4)')
tdSql.checkData(0, 3, 4)
tdLog.info('tdSql.checkData(0, 3, "4")')
tdSql.checkData(0, 3, "4")
# TSIM: return -1
# TSIM: endi
# TSIM:
......@@ -567,8 +567,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
tdLog.info('tdSql.checkData(0, 2, "1")')
tdSql.checkData(0, 2, "1")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data03 != 2 then
......@@ -582,8 +582,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data05 != 4 then
tdLog.info('tdSql.checkData(0, 5, 4)')
tdSql.checkData(0, 5, 4)
tdLog.info('tdSql.checkData(0, 5, "4")')
tdSql.checkData(0, 5, "4")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data06 != 5.000000000 then
......@@ -592,8 +592,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data07 != 6 then
tdLog.info('tdSql.checkData(0, 7, 6)')
tdSql.checkData(0, 7, 6)
tdLog.info('tdSql.checkData(0, 7, "6")')
tdSql.checkData(0, 7, "6")
# TSIM: return -1
# TSIM: endi
# TSIM:
......@@ -636,8 +636,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data02 != 7 then
tdLog.info('tdSql.checkData(0, 2, 7)')
tdSql.checkData(0, 2, 7)
tdLog.info('tdSql.checkData(0, 2, "7")')
tdSql.checkData(0, 2, "7")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data03 != 8 then
......@@ -646,8 +646,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data04 != 9 then
tdLog.info('tdSql.checkData(0, 4, 9)')
tdSql.checkData(0, 4, 9)
tdLog.info('tdSql.checkData(0, 4, "9")')
tdSql.checkData(0, 4, "9")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data05 != 10.000000000 then
......@@ -656,13 +656,17 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data06 != 11 then
tdLog.info('tdSql.checkData(0, 6, 11)')
tdSql.checkData(0, 6, 11)
tdLog.info('tdSql.checkData(0, 6, "11")')
tdSql.checkData(0, 6, "11")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data07 != NULL then
tdLog.info('tdSql.checkData(0, 7, NULL)')
try:
tdSql.checkData(0, 7, None)
except Exception as e:
tdLog.info(repr(e))
tdLog.info("out of range")
# TSIM: return -1
# TSIM: endi
# TSIM:
......@@ -682,8 +686,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data02 != 7 then
tdLog.info('tdSql.checkData(0, 2, 7)')
tdSql.checkData(0, 2, 7)
tdLog.info('tdSql.checkData(0, 2, "7")')
tdSql.checkData(0, 2, "7")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data03 != 8 then
......@@ -692,8 +696,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data04 != 9 then
tdLog.info('tdSql.checkData(0, 4, 9)')
tdSql.checkData(0, 4, 9)
tdLog.info('tdSql.checkData(0, 4, "9")')
tdSql.checkData(0, 4, "9")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data05 != 10.000000000 then
......@@ -702,13 +706,17 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data06 != 11 then
tdLog.info('tdSql.checkData(0, 6, 11)')
tdSql.checkData(0, 6, 11)
tdLog.info('tdSql.checkData(0, 6, "11")')
tdSql.checkData(0, 6, "11")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data07 != NULL then
tdLog.info('tdSql.checkData(0, 7, NULL)')
try:
tdSql.checkData(0, 7, None)
except Exception as e:
tdLog.info(repr(e))
tdLog.info("out of range")
# TSIM: return -1
# TSIM: endi
# TSIM:
......@@ -728,8 +736,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data02 != 7 then
tdLog.info('tdSql.checkData(0, 2, 7)')
tdSql.checkData(0, 2, 7)
tdLog.info('tdSql.checkData(0, 2, "7")')
tdSql.checkData(0, 2, "7")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data03 != 8 then
......@@ -738,8 +746,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data04 != 9 then
tdLog.info('tdSql.checkData(0, 4, 9)')
tdSql.checkData(0, 4, 9)
tdLog.info('tdSql.checkData(0, 4, "9")')
tdSql.checkData(0, 4, "9")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data05 != 10.000000000 then
......@@ -748,13 +756,17 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data06 != 11 then
tdLog.info('tdSql.checkData(0, 6, 11)')
tdSql.checkData(0, 6, 11)
tdLog.info('tdSql.checkData(0, 6, "11")')
tdSql.checkData(0, 6, "11")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data07 != NULL then
tdLog.info('tdSql.checkData(0, 7, NULL)')
try:
tdSql.checkData(0, 7, None)
except Exception as e:
tdLog.info(repr(e))
tdLog.info("out of range")
# TSIM: return -1
# TSIM: endi
# TSIM:
......@@ -774,8 +786,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data02 != 7 then
tdLog.info('tdSql.checkData(0, 2, 7)')
tdSql.checkData(0, 2, 7)
tdLog.info('tdSql.checkData(0, 2, "7")')
tdSql.checkData(0, 2, "7")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data03 != 8 then
......@@ -784,8 +796,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data04 != 9 then
tdLog.info('tdSql.checkData(0, 4, 9)')
tdSql.checkData(0, 4, 9)
tdLog.info('tdSql.checkData(0, 4, "9")')
tdSql.checkData(0, 4, "9")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data05 != 10.000000000 then
......@@ -794,13 +806,17 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data06 != 11 then
tdLog.info('tdSql.checkData(0, 6, 11)')
tdSql.checkData(0, 6, 11)
tdLog.info('tdSql.checkData(0, 6, "11")')
tdSql.checkData(0, 6, "11")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data07 != NULL then
tdLog.info('tdSql.checkData(0, 7, NULL)')
try:
tdSql.checkData(0, 7, None)
except Exception as e:
tdLog.info(repr(e))
tdLog.info("out of range")
# TSIM: return -1
# TSIM: endi
# TSIM:
......@@ -820,8 +836,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data02 != 7 then
tdLog.info('tdSql.checkData(0, 2, 7)')
tdSql.checkData(0, 2, 7)
tdLog.info('tdSql.checkData(0, 2, "7")')
tdSql.checkData(0, 2, "7")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data03 != 8 then
......@@ -830,8 +846,8 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data04 != 9 then
tdLog.info('tdSql.checkData(0, 4, 9)')
tdSql.checkData(0, 4, 9)
tdLog.info('tdSql.checkData(0, 4, "9")')
tdSql.checkData(0, 4, "9")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data05 != 10.000000000 then
......@@ -840,21 +856,25 @@ class TDTestCase:
# TSIM: return -1
# TSIM: endi
# TSIM: if $data06 != 11 then
tdLog.info('tdSql.checkData(0, 6, 11)')
tdSql.checkData(0, 6, 11)
tdLog.info('tdSql.checkData(0, 6, "11")')
tdSql.checkData(0, 6, "11")
# TSIM: return -1
# TSIM: endi
# TSIM: if $data07 != NULL then
tdLog.info('tdSql.checkData(0, 7, NULL)')
try:
tdSql.checkData(0, 7, None)
except Exception as e:
tdLog.info(repr(e))
tdLog.info("out of range")
# TSIM: return -1
# TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('sql drop database $db')
tdSql.execute('sql drop database $db')
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
......
......@@ -216,20 +216,26 @@ class TDSql:
if order == "" or order.upper() == "ASC":
if all(sorted(list) == list):
tdLog.info("sql:%s, column :%d is sorted in accending order as expected" %
tdLog.info(
"sql:%s, column :%d is sorted in accending order as expected" %
(self.sql, col))
else:
tdLog.exit("%s failed: sql:%s, col:%d is not sorted in accesnind order" %
tdLog.exit(
"%s failed: sql:%s, col:%d is not sorted in accesnind order" %
(callerFilename, self.sql, col))
elif order.upper() == "DESC":
if all(sorted(list, reverse=True) == list):
tdLog.info("sql:%s, column :%d is sorted in decending order as expected" %
tdLog.info(
"sql:%s, column :%d is sorted in decending order as expected" %
(self.sql, col))
else:
tdLog.exit("%s failed: sql:%s, col:%d is not sorted in decending order" %
tdLog.exit(
"%s failed: sql:%s, col:%d is not sorted in decending order" %
(callerFilename, self.sql, col))
else:
tdLog.exit("%s failed: sql:%s, the order provided for col:%d is not correct" %
tdLog.exit(
"%s failed: sql:%s, the order provided for col:%d is not correct" %
(callerFilename, self.sql, col))
tdSql = TDSql()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册