insert_wide_coulum.py 2.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
# -*- coding: utf-8 -*-

import sys
from util.log import *
from util.cases import *
from util.sql import *
from util.autogen import *
import threading
import random
import string
import time


A
Alex Duan 已提交
14 15 16 17 18 19 20 21 22 23 24 25
class TDTestCase:
    def init(self, conn, logSql, replicaVar=1):
        tdSql.init(conn.cursor(), logSql)

    def run(self):  
        tdLog.info("hello world.")

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


26 27 28
#
# Test Main class
#
A
Alex Duan 已提交
29 30

'''
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
class TDTestCase:
    def init(self, conn, logSql, replicaVar=1):
        self.replicaVar = int(replicaVar)
        tdLog.debug("start to execute %s" % __file__)
        tdSql.init(conn.cursor(), logSql)
        self.autoGen = AutoGen()

    def query_test(self, stbname):
        sql = f"select count(*) from {stbname}"
        tdSql.execute(sql)
        sql = f"select * from {stbname} order by ts desc;"
        tdSql.execute(sql)
        sql = f"select * from (select * from {stbname} where c1=c2 or c3=c4 or c5=c6) order by ts desc;"
        tdSql.execute(sql)

        tdLog.info(" test query ok!")


    def test_db(self, dbname, stbname, childname, tag_cnt, column_cnt, child_cnt, insert_rows, binary_len, nchar_len):    
        self.autoGen.create_db(dbname)
        self.autoGen.create_stable(stbname, tag_cnt, column_cnt, binary_len, nchar_len)
        self.autoGen.create_child(stbname, childname, child_cnt)
        self.autoGen.insert_data(insert_rows)
        self.autoGen.insert_samets(insert_rows)
        self.query_test(stbname)

    def run(self):  
        dbname = "test"
        stbname = "st"
        childname = "d"
A
Alex Duan 已提交
61 62
        child_cnt = 2
        insert_rows = 10
63
        tag_cnt    = 15
A
Alex Duan 已提交
64 65 66 67
        column_cnt = 20
        binary_len = 10240
        nchar_len =  1025
        self.autoGen.set_batch_size(1)
68 69 70 71 72 73 74
        
        # normal
        self.test_db(dbname, stbname, childname, tag_cnt, column_cnt, child_cnt, insert_rows, binary_len, nchar_len)

        # max
        dbname = "test_max_col"
        child_cnt = 3
A
Alex Duan 已提交
75
        insert_rows = 50
76 77 78 79 80 81 82 83 84 85 86
        tag_cnt = 128
        binary_len = 3
        nchar_len = 4
        column_cnt = 4096 - tag_cnt
        self.autoGen.set_batch_size(1)
        self.test_db(dbname, stbname, childname, tag_cnt, column_cnt, child_cnt, insert_rows, binary_len, nchar_len)
        

    def stop(self):
        tdSql.close()
        tdLog.success("%s successfully executed" % __file__)
A
Alex Duan 已提交
87
'''
88 89 90

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