Skip to content

Commit

Permalink
Merge pull request #23803 from taosdata/ts4295
Browse files Browse the repository at this point in the history
add test case for ts-4295
  • Loading branch information
DuanKuanJun committed Nov 27, 2023
2 parents e85c634 + e2c5902 commit b6f007b
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/parallel_test/cases.task
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ e
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/precisionUS.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/precisionNS.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_ts4219.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_ts4295.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_td27388.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/show.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/show_tag_index.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/information_schema.py
Expand Down
97 changes: 97 additions & 0 deletions tests/system-test/1-insert/test_td27388.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import random
import string
from util.log import *
from util.cases import *
from util.sql import *
from util.sqlset import *
from util import constant
from util.common import *


class TDTestCase:
"""Verify the insert with format exception for task TD-27388
"""
def init(self, conn, logSql, replicaVar=1):
self.replicaVar = int(replicaVar)
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
self.dbname = 'db'
self.stbname = 'st'
tdSql.execute("create database {};".format(self.dbname))
tdSql.execute("use {};".format(self.dbname))
tdSql.execute("create table st (ts timestamp, col1 int, col2 varchar(64)) tags (t1 int, t2 varchar(32));")

def test_half_quotes(self):
sql_list = [
"insert into t1 using st tags(1, 'tag1) values(now, 1, 'test msg');",
"insert into t1 using st tags(1, tag1') values(now, 1, 'test msg');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg);",
"insert into t1 using st tags(1, 'tag1') values(now, 1, test msg');",
"insert into t1 using st tags(1, 'tag1' values(now, 1, test msg');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg)';",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg);",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg') t2 using st tags(2, 'tag2) values(now, 2, 'test msg');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg') t2 using st tags(2, tag2') values(now, 2, 'test msg');",
"insert into t1 using st tags(1, 'tag1) values(now, 1, 'test msg') t2 using st tags(2, 'tag2) values(now, 2, 'test msg');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg) t2 using st tags(2, 'tag2') values(now, 2, test msg');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg') t2 using st tags(2, 'tag2') values(now, 2, 'test msg);",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg') t2 using st tags(2, 'tag2') values(now, 2, 'test msg);"
]
for sql in sql_list:
tdLog.debug("execute harlf quotes sql: %s" % sql)
tdSql.error(sql)

def test_esc(self):
sql_list = [
"insert into t1 using st tags(1, 'tag1\\') values(now, 1, 'test msg');",
"insert into t1 using st tags(1, \\'tag1') values(now, 1, 'test msg');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg\\');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, \\'test msg');",
"insert into t1 using st tags(1, \\'tag1\\') values(now, 1, 'test msg');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, \\'test msg\\');",
"insert into t1 using st tags(1, \\'tag1\\') values(now, 1, \\'test msg\\');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg') t2 using st tags(2, 'tag2\\') values(now, 2, 'test msg');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg') t2 using st tags(2, \\'tag2') values(now, 2, 'test msg');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg') t2 using st tags(2, 'tag2') values(now, 2, \\'test msg');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg') t2 using st tags(2, 'tag2') values(now, 2, 'test msg\\');",
"insert into t1 using st tags(1, \\'tag1') values(now, 1, 'test msg') t2 using st tags(2, 'tag2\\') values(now, 2, 'test msg');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg') t2 using st tags(2, 'tag2') values(now, 2, \\'test msg\\');"
]
for sql in sql_list:
tdLog.debug("execute escape character sql: %s" % sql)
tdSql.error(sql)

def test_specific_character(self):
sql_list = [
"insert into t1 using st tags(1, 'tag1$) values(now, 1, 'test msg');",
"insert into t1 using st tags(1, 'tag1,) values(now, 1, 'test msg');",
"insert into t1 using st tags(1, 'tag1'') values(now, 1, 'test msg');",
"insert into t1 using st tags(1, 'tag1() values(now, 1, 'test msg');",
"insert into t1 using st tags(1, 'tag1*) values(now, 1, 'test msg');",
"insert into t1 using st tags(1, 'tag1+) values(now, 1, 'test msg');",
"insert into t1 using st tags(1, 'tag1,) values(now, 1, 'test msg');",
"isnert into t1 using st tags(1, 'tag1-) values(now, 1, 'test msg');",
"insert into t1 using st tags(1, 'tag1.) values(now, 1, 'test msg');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg$);",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg,);",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg+%+-.);",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg') t2 using st tags(2, 'tag2$) values(now, 2, 'test msg');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg') t2 using st tags(2, 'tag2,) values(now, 2, 'test msg');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg') t2 using st tags(2, 'tag2'') values(now, 2, 'test msg');",
"insert into t1 using st tags(1, 'tag1') values(now, 1, 'test msg') t2 using st tags(2, 'tag2() values(now, 2, 'test msg');"
]
for sql in sql_list:
tdLog.debug("execute specific character sql: %s" % sql)
tdSql.error(sql)

def run(self):
self.test_half_quotes()
self.test_esc()
self.test_specific_character()

def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)

tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
49 changes: 49 additions & 0 deletions tests/system-test/1-insert/test_ts4295.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import os
import sys
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import tdDnodes
from math import inf
import taos

class TDTestCase:
"""Verify inserting varbinary type data of ts-4295
"""
def init(self, conn, logSql, replicaVer=1):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), True)
self.conn = conn
self.db_name = "db"
self.stable_name = "st"

def run(self):
tdSql.execute("create database if not exists %s" % self.db_name)
tdSql.execute("use %s" % self.db_name)
# create super table
tdSql.execute("create table %s (ts timestamp, c1 varbinary(32)) tags (t1 int)" % self.stable_name)
# create child table
child_table_list = []
for i in range(10):
child_table_name = "ct_" + str(i+1)
child_table_list.append(child_table_name)
tdSql.execute("create table %s using st tags(%s);" % (child_table_name, str(i+1)))
tdLog.info("create table %s successfully" % child_table_name)
# insert data
for i in range(100):
sql = "insert into table_name values"
for j in range(10000):
sql += "(now+%ss, '0x7661726331')," % str(j+1)
for child_table in child_table_list:
tdSql.execute(sql.replace("table_name", child_table))
tdLog.info("Insert data into %s successfully" % child_table)
tdLog.info("Insert data round %s successfully" % str(i+1))
tdSql.execute("flush database %s" % self.db_name)

def stop(self):
tdSql.execute("drop database if exists %s" % self.db_name)
tdSql.close()
tdLog.success("%s successfully executed" % __file__)

tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

0 comments on commit b6f007b

Please sign in to comment.